I know there are a lot of articles and notes about this, but I can't find any good client and server examples.
Also, I'm not understanding exactly what should the Nginx server do after the first handshake.
There's an upgrade header, I know that, but from a perspective of a sysadmin, what are the changes that needs to be done so the servers create and maintain open a connection of WS?
For the client side, I wrote this:
window.onload = function() {
var socket = new WebSocket('wss://echo.websocket.org');
socket.onopen = function(event) {
console.log('conectat');
socket.send("Here's some text that the server is urgently awaiting!");
};
}
I'm not understanding how to write the server side code, and in what. For the example above, I just want a sample code of the server side that sends back whatever I send to the server. What this code will look like?
I appreciate any schema/sample of code, but please don't provide stuff like "Try Socket.IO". I need something raw so I can understand exactly what is happening.