Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ECONNRESET #573

Closed
Blixia opened this issue Jan 14, 2016 · 6 comments
Closed

ECONNRESET #573

Blixia opened this issue Jan 14, 2016 · 6 comments

Comments

@Blixia
Copy link

@Blixia Blixia commented Jan 14, 2016

I am getting the following error while I add a torrent to the client:

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: write ECONNRESET
    at errnoException (net.js:901:11)
    at Object.afterWrite (net.js:718:19)

I am not sure where to catch this error or where it is coming from?

Code used:

'use strict';

var webTorrent = require('webtorrent');
var fs = require('fs');

var client = new webTorrent();
var magnet = '';

client.add(magnet,function(torrent)
{
    client.on('torrent',function(torrent)
    {
        console.log(torrent.infoHash);
    });

    torrent.on('done',function()
    {
        console.log('done downloading');
        torrent.files.forEach(function(file)
        {
            file.getBuffer(function(err,buffer)
            {
                if(err) throw err;

                fs.appendFile('./downloads/'+file.name,buffer,function(err)
                {
                    if(err) return console.log(err);
                    console.log('appending');
                })
            });
        });
    });

    torrent.on('download', function(chunkSize)
    {
      console.log('chunk size: ' + chunkSize);
      console.log('total downloaded: ' + torrent.downloaded);
      console.log('download speed: ' + torrent.downloadSpeed);
      console.log('progress: ' + torrent.progress);
      console.log('======');
    });

});
@feross

This comment has been minimized.

Copy link
Member

@feross feross commented Feb 11, 2016

@Blixia I added some extra checks to bittorrent-swarm so we're more defensive against remote sockets potentially closing without warning (which is the source of this error).

Can you re-install WebTorrent and try it out again? The problem should be gone, but don't hesitate to leave a comment here or open a new issue if you see this again.

@feross feross closed this Feb 11, 2016
@anurupr

This comment has been minimized.

Copy link

@anurupr anurupr commented Aug 8, 2016

I'm receiving this error when using the following snippet

 torrent.on('done', function(){
     const torrentPath = torrent.path;
        console.log('torrent finished downloading located at ',torrentPath);
        console.log("File count",torrent.files.length);
        var list = [];
        torrent.files.forEach(function(file){
            list.push(file.createReadStream());
           console.log(file.name);
        });

        client.seed(list,function(ntorrent){
            const magnetURI = ntorrent.magnetURI;
            console.log("magnetURI",magnetURI);

        });

      });
@feross

This comment has been minimized.

Copy link
Member

@feross feross commented Aug 8, 2016

@anurupr Why are you calling client.seed on the same files after they are done? The client will automatically seed the files when the download is complete. No need for this extra code.

torrent.on('done', function () {
  const torrentPath = torrent.path
  console.log('Torrent finished downloading located at ', torrentPath)
  console.log('Torrent file count is ', torrent.files.length)
  console.log('Torrent magnet link is ', torrent.magnetURI)
})
@anurupr

This comment has been minimized.

Copy link

@anurupr anurupr commented Aug 9, 2016

@feross I apologize. I was not aware of that. Thanks for the help.

@feross

This comment has been minimized.

Copy link
Member

@feross feross commented Aug 10, 2016

No problem!

@lock

This comment has been minimized.

Copy link

@lock lock bot commented May 4, 2018

This thread has been automatically locked because it has not had recent activity. To discuss futher, please open a new issue.

@lock lock bot locked as resolved and limited conversation to collaborators May 4, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.