I'm using libtorrent 1.0.9 and custom bindings (reproducible with python). Sometimes I can not download magnets because they're stuck without metadata (while there're >200 DHT nodes available). I'm able to reproduce the issue with this magnet:
magnet:?xt=urn:btih:565DB305A27FFB321FCC7B064AFD7BD73AEDDA2B&dn=bbb_sunflower_1080p_60fps_normal.mp4&tr=udp%3a%2f%2ftracker.openbittorrent.com%3a80%2fannounce&tr=udp%3a%2f%2ftracker.publicbt.com%3a80%2fannounce&ws=http%3a%2f%2fdistribution.bbb3d.renderfarming.net%2fvideo%2fmp4%2fbbb_sunflower_1080p_60fps_normal.mp4
Meanwhile in other torrent clients (qBittorrent, Vuze) it gets the metadata very quickly. It's reproducible with following code:
import libtorrent as lt
import time
session = lt.session()
session.listen_on(6881, 6891)
session.add_extension('ut_metadata')
session.add_extension('ut_pex')
session.add_extension('metadata_transfer')
session.add_dht_router("router.utorrent.com", 6881)
session.add_dht_router("router.bittorrent.com", 6881)
session.add_dht_router("dht.transmissionbt.com", 6881)
session.add_dht_router("dht.aelitis.com", 6881)
session.start_dht()
session.start_lsd()
session.start_upnp()
session.start_natpmp()
params = { 'save_path': '/tmp/'}
link ="magnet:?xt=urn:btih:565DB305A27FFB321FCC7B064AFD7BD73AEDDA2B&dn=bbb_sunflower_1080p_60fps_normal.mp4&tr=udp%3a%2f%2ftracker.openbittorrent.com%3a80%2fannounce&tr=udp%3a%2f%2ftracker.publicbt.com%3a80%2fannounce&ws=http%3a%2f%2fdistribution.bbb3d.renderfarming.net%2fvideo%2fmp4%2fbbb_sunflower_1080p_60fps_normal.mp4"
handle = lt.add_magnet_uri(session, link, params)
print('downloading metadata...')
while (not handle.has_metadata()):
status=session.status()
print('dht nodes: ', status.dht_nodes)
time.sleep(1)
print ('got metadata, starting torrent download...')
while (handle.status().state != lt.torrent_status.seeding):
print('%d %% done' % (handle.status().progress*100))
time.sleep(1)
What I'm doing wrong?