I am using web sockets to connect to localhost as seen below. I am using native web sockets on the client and express-ws on the server.
This was working fine and stopped for some reason. The only changes I can remember making were formatting using ESLint.
How can I troubleshoot this further. The server is showing no error. The client error gives no useful info.
CLIENT
const socket = new WebSocket('ws://localhost:3000/echo');
socket.addEventListener('error', function(event) {
console.log('DEBUG: WebSocket error:', event);
});
SERVER
function ws(app) {
const expressWs = require('express-ws')(app);
console.log('DEBUG: websocket server up');
app.ws('/echo', (ws, req) => {
ws.on('message', (msg) => {
ws.send(msg);
});
});
}
module.exports = ws;
CLIENT ERROR:
WebSocket connection to 'ws://localhost:3000/echo' failed: