javascript - WebSocket connection closes when server sends message only on port 80 -


i have simple, local nodejs server running express. i'm using express-ws set websocket endpoint. client sends messages fine, , server receives them, when server tries send message back, connection closes , client never receives message.

this happens on port 80. connection stays open on port 3000, 8080, 443, , client receives messages server sends back.

app.js

const express = require('express'); const path = require('path'); const app = express(); const expressws = require('express-ws')(app);  app.use(express.static(path.join(__dirname, 'public')));  app.get('/', function(req, res, next){   res.send(`<script src="js/client.js"></script>`); });  app.ws('/', function(ws, req) {   ws.on('message', function(msg) {     console.log(msg);     ws.send(msg); //the connection doesn't close commented out   }); });  app.listen(80); 

client.js

const ws = new websocket(`ws://${window.location.host}`);  ws.onopen = function(e){   console.log("websocket connected");     ws.send("testing 1");     ws.send("testing 2"); }  ws.onmessage = function(msg){   console.log(msg); } 

i'm @ loss. appreciated.


Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -