express-ws icon indicating copy to clipboard operation
express-ws copied to clipboard

express-ws route does not work on heroku

Open pivcec opened this issue 8 years ago • 2 comments

When I browse to the following websocket enabled route on localhost, then it works fine ("hello from player route" is returned). I am also able to sent messages to it via websockets. When I deploy this app to Heroku, then I am able to browse to this route ok, but when I try to connect via websocket (through debugger tool), then it never connects, and I get a server error.

app.js:

const express = require('express'); let expressWs = require('express-ws'); expressWs = expressWs(express()); const app = expressWs.app; const router = express.Router(); ... const playerRouter = require('./routes/player')(router); ... module.exports = app;

player.js:

`module.exports = (router, db) => { router.get('/api/player/:id', (req, res, next) => { res.send('hello from player route'); res.end(); });

router.ws('/api/player/:id', (ws, req) => { ws.on('message', msg => { console.log('msg', msg); }); }); }`

Error on server:

heroku[router]: at=error code=H13 desc="Connection closed without response" method=GET path="/api/player/1" host=shielded-river-25076.herokuapp.com request_id=1ea0d954-7b06-4f46-b86f-6016cb910be4 fwd="2.229.13.61" dyno=web.1 connect=0ms service=1ms status=503 bytes=0 protocol=http

pivcec avatar Jun 10 '18 13:06 pivcec

dont't use this ! express-ws is shit!

ApolloRoad avatar Jun 10 '18 22:06 ApolloRoad

@pivcec This module has problems when you use identical routes for get and ws. Try find more in: https://github.com/HenningM/express-ws/issues/64 and https://github.com/HenningM/express-ws/pull/68

Or I'm wrong...

bato3 avatar Jul 06 '18 14:07 bato3