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

engine io and Express on the same port #546

Closed
1 of 3 tasks
dennisat opened this issue Dec 10, 2017 · 1 comment
Closed
1 of 3 tasks

engine io and Express on the same port #546

dennisat opened this issue Dec 10, 2017 · 1 comment

Comments

@dennisat
Copy link

You want to:

  • report a bug
  • request a feature
  • help how to setup my app for Heroku

Current behaviour

Hello engine io

I want to load the engineIo together with an Express application on the same port.

I managed to do that with the follow way:

import express from 'express';
const engineIo = require('engine.io');

export const serverPort = process.env.PORT || 3222;		// grab the port of the environment or use the dev 3222

const appExpress = express();
const httpServer = http.createServer(appExpress);	
const wsServer = engineIo(httpServer);
httpServer.listen(serverPort);							// here the server starts to listen

This works perfectly on my machine.
The Express application is working correctly as webserver and as api server and the services that use websockets are also working properly!

But... on production environment, in precise on Heroku, although I grap the correct port number I get the error EADDRINUSE, (error address is in use).
I am getting this error after both Express and Websocket instances are initialized (without errors).

The EADDRINUSE is a known error when you load the websocket server on a port that it is already used from another application.

This is the heroku error log:

2017-12-10T18:56:08.466921+00:00 app[web.1]: Error: listen EADDRINUSE :::8212
2017-12-10T18:56:08.466922+00:00 app[web.1]:     at Object._errnoException (util.js:1024:11)
2017-12-10T18:56:08.466923+00:00 app[web.1]:     at _exceptionWithHostPort (util.js:1046:20)
2017-12-10T18:56:08.466927+00:00 app[web.1]:     at Server.setupListenHandle [as _listen2] (net.js:1351:14)
2017-12-10T18:56:08.466928+00:00 app[web.1]:     at listenInCluster (net.js:1392:12)
2017-12-10T18:56:08.466929+00:00 app[web.1]:     at Server.listen (net.js:1476:7)
2017-12-10T18:56:08.466930+00:00 app[web.1]:     at Function.listen (/app/server/node_modules/express/lib/application.js:618:24)
2017-12-10T18:56:08.466931+00:00 app[web.1]:     at dynaNodeServer.start.then.then (/app/server/dist/index.js:10873:9)
2017-12-10T18:56:08.466931+00:00 app[web.1]:     at <anonymous>
2017-12-10T18:56:08.466932+00:00 app[web.1]:     at process._tickCallback (internal/process/next_tick.js:188:7)

Any help is appreciated.

Setup

  • OS: heroku container
  • browser:
  • engine.io version: 3.1.1
@dennisat
Copy link
Author

Sorry, nothing is wrong with this setup.
There was an issue with the deploy process and the container.

darrachequesne pushed a commit that referenced this issue May 8, 2020
Some WebSocket implementations require the protocols parameter or will
fail connection.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant