【发布时间】:2015-01-21 17:23:32
【问题描述】:
我想在我的项目中使用 DHT,但我无法让 Kademlia example 正常工作。
这是twistd -noy examples/server.tac的输出日志:
2015-01-21 18:19:43+0100 [-] Log opened.
2015-01-21 18:19:43+0100 [-] twistd 13.2.0 (/usr/bin/python 2.7.6) starting up.
2015-01-21 18:19:43+0100 [-] reactor class: twisted.internet.epollreactor.EPollReactor.
2015-01-21 18:19:43+0100 [-] KademliaProtocol starting on 8468
2015-01-21 18:19:49+0100 [-] 'Did not received reply for msg id YES6sdvjJ3qpg5Pr6pg/ajdeMg8= within 5 seconds'
2015-01-21 18:19:49+0100 [NodeSpiderCrawl] [INFO] creating spider with peers: []
2015-01-21 18:19:49+0100 [NodeSpiderCrawl] [INFO] crawling with nearest: ()
2015-01-21 18:19:49+0100 [NodeSpiderCrawl] [INFO] last iteration same as current - checking all in list now
2015-01-21 18:19:53+0100 [Server] [WARNING] No known neighbors, so not writing to cache.
这是上面链接中的客户端脚本的输出:
2015-01-21 18:22:09+0100 [-] Log opened.
2015-01-21 18:22:09+0100 [-] KademliaProtocol starting on 5678
2015-01-21 18:22:14+0100 [-] 'Did not received reply for msg id SpQjdpv2Qos+C7q0BB1XzNgya4A= within 5 seconds'
2015-01-21 18:22:14+0100 [NodeSpiderCrawl] [INFO] creating spider with peers: []
2015-01-21 18:22:14+0100 [NodeSpiderCrawl] [INFO] crawling with nearest: ()
2015-01-21 18:22:14+0100 [NodeSpiderCrawl] [INFO] last iteration same as current - checking all in list now
2015-01-21 18:22:14+0100 [-] Found nodes: []
2015-01-21 18:22:14+0100 [Server] [DEBUG] setting 'a key' = 'a value' on network
2015-01-21 18:22:14+0100 [Server] [WARNING] There are no known neighbors to set key a key
2015-01-21 18:22:14+0100 [Server] [WARNING] There are no known neighbors to get key a key
2015-01-21 18:22:14+0100 [-] Key result: None
2015-01-21 18:22:14+0100 [KademliaProtocol (UDP)] (UDP Port 5678 Closed)
2015-01-21 18:22:14+0100 [-] Main loop terminated.
发生了什么事?我知道一个对等点需要一个网络来连接,但这不就是独立服务器应该做的吗?
提前致谢!
【问题讨论】:
-
客户端/服务器的区别实际上并不存在于 p2p 网络中。那么,您是否告诉节点 2 如何联系节点 1?而且您的日志文件没有显示时间重叠,如果它们不是同时启动,它们就无法真正相互交谈。
-
@the8472,Kademlia 文档将两个脚本之一称为“独立服务器”,我也觉得这有点奇怪。事实上,这两个节点是同时启动和运行的。我不太确定需要做什么才能“告诉节点 2 如何联系节点 1”。将对等点指向 ip:port 不就足够了吗?
-
“不应该将对等点指向一个 ip:port 就足够了吗?”。确实应该,但日志消息似乎表明节点没有人可以交谈。
-
@the8472,是的,因此我对 StackOverflow 提出了问题;)尽管我承认我最好将问题表述为“为什么这些节点不能通信?”
-
那么,您是否调整了示例以反映您节点的实际 IP 地址?