1

我想在我的项目中使用 DHT,但我无法让Kademlia 示例正常工作。

这是来自的输出日志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.

这是怎么回事?我知道一个对等点需要一个网络来连接,但这不是独立服务器应该做的吗?

提前致谢!

4

1 回答 1

1

README 文件中客户端代码的引导地址不正确。存储库exmaple.py中的示例文件具有正确的行。

请换行:

server.bootstrap([('127.0.0.1', 1234)]).addCallback(done, server)

server.bootstrap([('127.0.0.1', 8468)]).addCallback(done, server)
于 2015-01-27T15:09:49.987 回答