anacrolix / dht

dht is used by anacrolix/torrent, and is intended for use as a library in other projects both torrent related and otherwise
Mozilla Public License 2.0
313 stars 66 forks source link

Example Ping timeout #57

Closed dusty-cjh closed 2 years ago

dusty-cjh commented 2 years ago

Here is my try: go run ./cmd/dht ping router.bittorrent.com:6881 router.utorrent.com:6881

2022/01/06 14:16:01 main.go:63: public ip: "103.201.26.3"
2022/01/06 14:16:01 main.go:70: dht server on [::]:61082 with id 5d12d5586d35ce2eaf751ef3af0812935955529b
router.utorrent.com:6881: 2.003219305s: after 1 tries: transaction timed out
router.bittorrent.com:6881: 2.004312261s: after 1 tries: transaction timed out

And here is my capture from tcpdump image

Actually I also met this question when I using python. Does my operation right ? Could you please give me some advice, thank you very much !

anacrolix commented 2 years ago

There's no guarantee that pings, or that the bootstrap nodes will respond, particularly if your IP has made a lot of queries recently. For me:

$ go run -v -race ./cmd/dht ping router.bittorrent.com:6881 router.utorrent.com:6881 --timeout 10s
2022/01/06 22:31:23 main.go:63: public ip: "49.180.133.148"
2022/01/06 22:31:23 main.go:70: dht server on [::]:60773 with id 51461a61d0421b1b8d1957b9ae94d295b4f8853c
router.bittorrent.com:6881: 32f54e697351ff4aec29cdbaabf2fbe3467cc267 ✔: 175.128186ms
router.utorrent.com:6881: 2.000993201s: after 1 tries: transaction timed out

If your network is very slow, or UDP is lossy, you might have trouble getting through. You could provide a higher timeout with the --timeout flag, although I notice that doesn't seem to affect the timeout in ./cmd/dht, that could be a bug.

anacrolix commented 2 years ago

I'll close this in favour of the discussion, https://github.com/anacrolix/dht/discussions/59.