question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Generate .torrent and start seeding immediately

See original GitHub issue

I want to transfer file with magnetLink in c#. Through googling found monotorrent is best. I made a public bittorrent tracker server with https://github.com/webtorrent/bittorrent-tracker. I tried to generate .torrent file and get magnet link from media file in my pc. I used this sample. https://smuxi.im/wiki/monotorrent/Creating_Torrents. Open my .torrent file in mine and uTorrent program, but cannot download. I tried using uTorrent and generate a .torrent from same media file, and it works well in both uTorrent and monoTorrent. I found that the torrent’s info hash value is different in monotorrent and uTorrent. I have also tried to get magnet link from webtorrent. The infohash values in magnet url are same from uTorrent and webtorrent. The only my info hash differs. What’s the reason? Please help me. Here is my code to generate .torrent file and get magnet link. DevEnv : Windows10 / Visual studio 2017 / .Net framework 4.6.1

public async void CreateAndLoadTorrent(string path)
{
    ClientEngine engine = new ClientEngine(new EngineSettings());

    TorrentCreator creator = new TorrentCreator();
    creator.Announces.Add(new RawTrackerTier(new[] { "http://192.168.5.151:8000/announce", "udp://192.168.5.151:8000"}));
    ITorrentFileSource files = new TorrentFileSource(path);

    BEncodedDictionary dict = await creator.CreateAsync(files);
    Torrent torrent = Torrent.Load(dict);


    BitField bitfield = new BitField(torrent.Pieces.Count).Not();
    FastResume fastResumeData = new FastResume(torrent.InfoHash, bitfield);

    TorrentManager manager = new TorrentManager(torrent, downloadPath, new TorrentSettings());
    manager.LoadFastResume(fastResumeData);

    engine.Register(manager);
    engine.StartAll();

    //MagnetLink magnet = new MagnetLink(manager.Torrent.InfoHash, manager.Torrent.Name, new[] { "http://192.168.5.151:8000/announce", "udp://192.168.5.151:8000" });
}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
alanmcgoverncommented, Mar 15, 2020

Open my .torrent file in mine and uTorrent program, but cannot download.

uTorrent will, by default, not allow connections from the same computer it is running on. i.e. if you run MonoTorrent and uTorrent on the same computer they will never connect to each other. You will need to go to the advanced settings and enable the bt.allow_same_ip option.

Apart from that uTorrent does have a great logger. I would recommend enabling the ‘Logging’ pane, turning on every option it allows, and then seeing if anything interesting shows up which might explain what’s going wrong.

I found that the torrent’s info hash value is different in monotorrent and uTorrent.

That’s not necessarily a bug or issue. The infohash is dependent on the ordering of the keys in the torrent file, and those aren’t always identical between programs which create a torrent. If you want to check if the .torrent file is valid then load the same .torrent into both MonoTorrent and uTorrent, point it at the same set of original files, then run a hash check. If both say that the torrent is 100% complete then great!

If you are still having issues then would it be possible to share the original files and the two .torrents with me (privately if necessary) so I can reproduce the issue and figure out what’s going on?

0reactions
ddddevvcommented, Mar 16, 2020

The downloadpath, i.e. 2nd parameter of new TorrentManager() function must be the directory of file to seed. TorrentManager manager = new TorrentManager(torrent, downloadPath, new TorrentSettings());

changed to

TorrentManager manager = new TorrentManager(torrent, Path.GetDirectoryName(path), new TorrentSettings());

It works well soon.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Create a Torrent File and Start Sharing 🎞️ - YouTube
In this video, I'm going to show you how to create a file and share it via torrent. Briefly, I will tell you...
Read more >
How to seed a file for first time??? - General
When you upload a torrent immediately it starts seeding . it doesn't downloads anything . I think you are not uploaded your torrent...
Read more >
How do I create a torrent and seed directly between two ...
In utorrent go to Options > Preferences > Advanced. · Change the Value of bt.enable_tracker to true. · On the left click Bittorrent....
Read more >
Why does BitTorrent start seeding before the download is ...
After the file is downloaded, your Torrent client automatically seeds the file so that other people can download parts of the file faster....
Read more >
How to create a private torrent using qBittorrent
Your torrent should start seeding immediately if you did it right. You can also verify this by navigating to the tracker tab, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found