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

Using with socket.io and express #192

Closed
brunobg opened this issue May 18, 2020 · 7 comments
Closed

Using with socket.io and express #192

brunobg opened this issue May 18, 2020 · 7 comments

Comments

@brunobg
Copy link
Contributor

brunobg commented May 18, 2020

I'm having an issue:

  • Give an expressive description of what is went wrong
    Starting an ExpressPeerServer in a server that runs express and socket.io breaks socket.io. Apparently both use the same port and this wrecks havoc, but this used to work with previous versions.

  • Version of peer you're experiencing this issue
    0.5.3

  • Nodejs version?
    v10

  • Platform name and its version (Win, Mac, Linux)?
    Linux. Also, socket.io 2.3.0.

  • Nice to have: a repository with code to reproduce the issue
    Sorry, don't have

  • If you're getting an error or exception, please provide its full stack-trace as plain-text or screenshot
    There's no error. socket.io starts, but app.use('/peerjs', peerserverSSL); breaks socket.io connections.

This used to work with "peerjs-server": "^0.2.9", but broke after updating to current.

Is this a bug or is peerjs now incompatible with socket.io? If incompatible, any suggestions for a workaround? Create a new peerjs server without using express perhaps? Thanks

@brunobg
Copy link
Contributor Author

brunobg commented Aug 12, 2020

so if anyone runs into this: no, you cannot run with express and socket.io at the same time. peerjs now seems to use the same websocket attachment to express than socketio. run a separate peerserver.

@brunobg brunobg closed this as completed Aug 12, 2020
@aniket-banyal
Copy link

Hi. I am facing the same issue. Please can u explain a but more about how to run a separate peerserver. Thanks!

@brunobg
Copy link
Contributor Author

brunobg commented Oct 13, 2020

@Dummy26 Create it directly like https://github.com/peers/peerjs-server#create-a-custom-server

@muratkemaldar
Copy link

muratkemaldar commented Nov 4, 2020

I am having issues because of this combo as well. I am running my Express App on Heroku and I only have a single port which I can use. This is why I would like to use the ExpressPeerServer and not a separate one.

Where do you deploy your app when you have a port for your Express Server and one for the Peer Server? @brunobg

EDIT:
I now decided to to run a separate Heroku App with a PeerServer.

@lmf-git
Copy link

lmf-git commented Nov 24, 2020

Same problem too, I'm not willing to use two different websockets just due to the laziness of the developers of this project.

@brunobg
Copy link
Contributor Author

brunobg commented Nov 25, 2020

This issue should be locked. I'm the OP of this issue. This is not a bug and I understand very well why it was implemented like this.

If someone reaches this from Google, final guideline:

  • peerjs and socketio use websockets attach to express the same way. It's not viable to change that.
  • you can easily create a PeerServer with its own websocket, with no other drawbacks. It's well documented here: https://github.com/peers/peerjs-server#create-a-custom-server It's literally two extra lines.
  • I posted a PR which was accepted and allow you to create a websocket with all the https options supported by nodejs. It didn't at the time I created this issue, which was a limitation to what I needed to do.

I won't post anymore on this issue.

@shokhboz-abdullaev

This comment was marked as off-topic.

@peerjs-bot
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@peers peers locked as resolved and limited conversation to collaborators Feb 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants