Anybody knows how to setup a websocket server nodejs (npm package ws) app service on Azure ? My ws client can't connect to the ws server... Thank you for any hint!
Seems you missed something to start up your application. I write a sample demo for you,the project secture is simple just like below:
Code of wstest.js
:
const WebSocket = require('ws');
const port = process.env.PORT || 8080
const wss = new WebSocket.Server({ port });
wss.on('connection', function connection(ws) {
ws.on('message', function incoming(message) {
console.log('received: %s', message);
});
ws.send('something from server');
});
I use vs code to deploy this project directly, so that this project will under folder : /home/site/wwwroot/
so we should use node command to start up it, just as below: