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

Error: invalid addr: undefined:undefined #398

Closed
Stiveknx opened this issue Aug 10, 2015 · 7 comments
Closed

Error: invalid addr: undefined:undefined #398

Stiveknx opened this issue Aug 10, 2015 · 7 comments
Labels

Comments

@Stiveknx
Copy link
Contributor

@Stiveknx Stiveknx commented Aug 10, 2015

In one many of my tests, this error appears, and, after it the download stops..

/home/steinn/novosl-client/node_modules/webtorrent-hybrid/node_modules/webtorrent/node_modules/addr-to-ip-port/index.js:13
    if (!m) throw new Error('invalid addr: ' + addr)
                  ^
Error: invalid addr: undefined:undefined
    at addrToIPPort (/home/steinn/novosl-client/node_modules/webtorrent-hybrid/node_modules/webtorrent/node_modules/addr-to-ip-port/index.js:13:19)
    at Swarm._validAddr (/home/steinn/novosl-client/node_modules/webtorrent-hybrid/node_modules/webtorrent/node_modules/bittorrent-swarm/index.js:383:15)
    at Swarm._addIncomingPeer (/home/steinn/novosl-client/node_modules/webtorrent-hybrid/node_modules/webtorrent/node_modules/bittorrent-swarm/index.js:191:13)
    at Wire.<anonymous> (/home/steinn/novosl-client/node_modules/webtorrent-hybrid/node_modules/webtorrent/node_modules/bittorrent-swarm/lib/tcp-pool.js:206:13)
    at Wire.g (events.js:180:16)
    at Wire.emit (events.js:117:20)
    at Wire._onHandshake (/home/steinn/novosl-client/node_modules/webtorrent-hybrid/node_modules/webtorrent/node_modules/bittorrent-swarm/node_modules/bittorrent-protocol/index.js:391:8)
    at Wire.<anonymous> (/home/steinn/novosl-client/node_modules/webtorrent-hybrid/node_modules/webtorrent/node_modules/bittorrent-swarm/node_modules/bittorrent-protocol/index.js:665:12)
    at Wire._write (/home/steinn/novosl-client/node_modules/webtorrent-hybrid/node_modules/webtorrent/node_modules/bittorrent-swarm/node_modules/bittorrent-protocol/index.js:555:10)
    at doWrite (_stream_writable.js:226:10)
    at writeOrBuffer (_stream_writable.js:216:5)
    at Wire.Writable.write (_stream_writable.js:183:11)

I'm using webtorrent-hybrid 0.39.0.
Using node, not in command line...

@feross

This comment has been minimized.

Copy link
Member

@feross feross commented Aug 10, 2015

Please paste your code here, so I can take a look.

@Stiveknx

This comment has been minimized.

Copy link
Contributor Author

@Stiveknx Stiveknx commented Aug 10, 2015

Well, the file is big and require another ones...
Here's the most important part.

 var request = require('request');
var jsdom = require('jsdom');
var WebTorrent = require('webtorrent-hybrid');
var client = new WebTorrent();
var child_process = require('child_process');
var fs = require('fs');
        client.add(release_data.path,
            function (torrent) {
                console.log('Torrent Added');
/*              torrent.swarm.on('download', function(){
                        var progress = (100 * torrent.downloaded / torrent.parsedTorrent.length).toFixed(1);
                        console.log("Progresso: " + progress + "\r\n");
                });*/
                torrent.files.forEach(function (file) {
                    if (validFile(file.name)) {
                        console.log('Valid file: ' + file.name);
                        file.select();
                        stream = file.createReadStream();
                        stream.on('end', function () {
                            console.log('Stream Finished');
                            client.seed(file.path, function onTorrent(torrent) {
                                console.log('Seeding the file');
                                // Client is seeding the file!
                                release_data.magnet = torrent.magnetURI;
                                finishEpisode(release_data);
                            });
                        });
                    } else {
                        file.deselect();
                    }
                });
            });

Where release_data.path is the magnetURI ...

@Stiveknx

This comment has been minimized.

Copy link
Contributor Author

@Stiveknx Stiveknx commented Aug 15, 2015

@feross Is there anything else I can do to help you to fix this issue?

@shirotech

This comment has been minimized.

Copy link

@shirotech shirotech commented Oct 6, 2015

+1 same problem

@feross

This comment has been minimized.

Copy link
Member

@feross feross commented Jan 3, 2016

What version of node.js are you guys using? Can you confirm that this issue still happens on the latest version of webtorrent (0.68.0)?

@feross

This comment has been minimized.

Copy link
Member

@feross feross commented Jan 3, 2016

Thanks for reporting this issue. This was a tricky one.

It turns out there's an obscure edge case with node.js TCP servers where you can get a closed socket (i.e. one that's missing it's remoteAddress and remotePort properties) inside the 'connection' event handler. Super strange and rare, but apparently there are enough connections in bittorrent that it gets triggered surprisingly often.

Node.js issue: nodejs/node-v0.x-archive#7566
bittorrent-swarm commit to fix the issue: https://github.com/feross/bittorrent-swarm/commit/29e0a980501b4b61406e3fd8c2ce64cf76c2f493

You can re-install webtorrent and you'll get the fix.

@feross feross closed this Jan 3, 2016
@feross feross added area/node bug and removed need more info labels Jan 3, 2016
@lock

This comment has been minimized.

Copy link

@lock lock bot commented May 5, 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 5, 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.