allenkim67 / allen-torrent

Learn to build a bittorrent client in node.js
210 stars 53 forks source link

hangs after it opens the torrent #2

Open afullstopdot opened 7 years ago

afullstopdot commented 7 years ago

Hi Allen, i wanted to use allen-torrent as a quick way to download torrents after i have searched a few torrent APIs as part of a school project, however there is no documentation (granted this, i assume was a tut).

When i try:

node index.js path/to/file-torrent

It just hangs, no information before the hang either. I am quite sure i added all the npm dependencies. Why does it just hang?

allenkim67 commented 7 years ago

Hey I'm not sure why it would just hang. I tried running locally and was able to download one of my torrent files. I did notice however that the dependency for bignum was missing from the package.json file, so I fixed that but it should have shown up as an error if you tried to run index. It might be a problem with the torrent. Did you try downloading the same file from another torrent client and it worked? If so, one reason might be because it's relying on the DHT option which my client doesn't support. You're right that it is part of a tutorial and isn't meant to be a full featured torrent client. You can check out the tutorial here: https://allenkim67.github.io/bittorrent/2016/05/04/how-to-make-your-own-bittorrent-client.html. Otherwise I'm sure there are lots of other torrent clients if you need a dependable one.

On Wed, Jan 4, 2017 at 7:05 AM, Andre Marques notifications@github.com wrote:

Hi Allen, i wanted to use allen-torrent as a quick way to download torrents after i have searched a few torrent APIs as part of a school project, however there is no documentation (granted this, i assume was a tut).

When i try:

node index.js path/to/file-torrent

It just hangs, no information before the hang either. I am quite sure i added all the npm dependencies. Why does it just hang?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/allenkim67/allen-torrent/issues/2, or mute the thread https://github.com/notifications/unsubscribe-auth/AB7rZEeTfszBAWmjYuwnEtxrD6W1jw7wks5rOuJkgaJpZM4LaKYi .

sylflo commented 5 years ago

I am not really sure at all but when doing this

  socket.on('message', response => {
    if (respType(response) === 'connect') {
      console.log("Connect in socket");
      // 2. receive and parse connect response
      const connResp = parseConnResp(response);
      // 3. send announce request
      const announceReq = buildAnnounceReq(connResp.connectionId, torrent);
      udpSend(socket, announceReq, url);
    } else if (respType(response) === 'announce') {
      // 4. parse announce response
      const announceResp = parseAnnounceResp(response);
      // 5. pass peers to callback
      callback(announceResp.peers);
    }
  });

I can not see the console.log

EDIT. The problem was that the tracker is dead. I need to check the different trackers in the torrent file and find one or multiple that are working

gewoonniels commented 4 years ago

This was also happening by me. The problem was that torrent.announce was a http connection and not a udp connection. Most popular torrents these day have an "announce-list", to solve my problem i selected (if available) a udp connection from the "announce-list".

joojscript commented 4 years ago

Mine is still hanging indefinitely... I got it all exactly like his code and still not responding (tested my .torrent and it works on BitTorrent). I also tried cloning his repo and trying to download by the clone, and it hangs as well. Is someone out here who knows what is happening maybe?

georgebutter commented 3 years ago

Yeah mine is also hanging, no "message" event is ever fired on the socket. I can confirm the socket is listening, but there is never an error or message. My torrent is udp, and I have been able to download it using another client.

As gewooneils noted though that using the announce list to attempt to connect to another tracker until I find one that responds worked for me.

karanmottan commented 3 years ago

@ButsAndCats could you please explain further how you solved this problem

georgebutter commented 3 years ago

@karanmottan , there is a tracker list property that is an array of trackers that you can attempt to if the first tracker fails. I updated my code so that it iterates through each tracker until it finds one that connects.

destrophix commented 1 year ago

Can anyone provide a torrent file link for which this client works.