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

Pick an available port instead of crashing with "listen EADDRINUSE" #411

Closed
markhilton opened this issue Aug 30, 2015 · 7 comments
Closed

Pick an available port instead of crashing with "listen EADDRINUSE" #411

markhilton opened this issue Aug 30, 2015 · 7 comments

Comments

@markhilton
Copy link

@markhilton markhilton commented Aug 30, 2015

DEBUG INFO: webtorrent 0.60.1, node v0.12.7, darwin x64, exit 1
events.js:85
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE
at exports._errnoException (util.js:746:11)
at Server._listen2 (net.js:1156:14)
at listen (net.js:1182:10)
at Server.listen (net.js:1267:5)
at runDownload (/opt/local/lib/node_modules/webtorrent/bin/cmd.js:313:10)
at Object. (/opt/local/lib/node_modules/webtorrent/bin/cmd.js:147:3)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)

@feross

This comment has been minimized.

Copy link
Member

@feross feross commented Aug 30, 2015

This error means that the port WebTorrent wants to use (port 8000) is already in use. This could be from an other instance of WebTorrent, or any another program.

You can run WebTorrent on a different port by using the --port argument:

webtorrent --port 8001

I'll leave this issue open since we can do better here -- by either providing a friendlier error, or preferably, automatically picking an available port.

@markhilton

This comment has been minimized.

Copy link
Author

@markhilton markhilton commented Aug 30, 2015

Thanks!

@feross

This comment has been minimized.

Copy link
Member

@feross feross commented Aug 30, 2015

Leaving this issue open until we support automatically picking an available port instead of crashing.

@feross feross changed the title listen EADDRINUSE Pick an available port instead of crashing with "listen EADDRINUSE" Aug 30, 2015
@Stiveknx

This comment has been minimized.

Copy link
Contributor

@Stiveknx Stiveknx commented Sep 21, 2015

@feross I'm whiling to help on this.
It's ok to use an external package for that?
(I think it would be too much work doing this without).

https://github.com/baalexander/node-portscanner

@gillesdemey

This comment has been minimized.

Copy link
Contributor

@gillesdemey gillesdemey commented Sep 21, 2015

@Stiveknx It's not too much work actually, it can be done in just a few lines of code.

https://github.com/gillesdemey/grop/blob/master/index.js

There are countless modules on npm already, though it looks like node-portscanner has a few more bells and whistles.

@feross

This comment has been minimized.

Copy link
Member

@feross feross commented Sep 21, 2015

@Stiveknx Cool, happy to accept a PR from you that implements this. You might not need to use an open port finder, but instead pass 0 in as the port so the OS will automatically pick an available one.

@gillesdemey grop is a module done right – looks nice.

yciabaud pushed a commit to yciabaud/webtorrent that referenced this issue Sep 27, 2015
yciabaud pushed a commit to yciabaud/webtorrent that referenced this issue Sep 27, 2015
yciabaud pushed a commit to yciabaud/webtorrent that referenced this issue Sep 27, 2015
@yciabaud

This comment has been minimized.

Copy link
Contributor

@yciabaud yciabaud commented Sep 27, 2015

I made a little contribution on this, I believe this is what you were talking about...
Let me know if there is anything.

josephfrazier pushed a commit that referenced this issue Nov 9, 2015
yciabaud pushed a commit to yciabaud/webtorrent that referenced this issue Nov 9, 2015
@lock lock bot locked as resolved and limited conversation to collaborators May 6, 2018
bricewge pushed a commit to bricewge/webtorrent that referenced this issue May 11, 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
5 participants
You can’t perform that action at this time.