WebSocket: How to automatically reconnect after it dies

Here is what I ended up with. It works for my purposes. function connect() { var ws = new WebSocket(‘ws://localhost:8080’); ws.onopen = function() { // subscribe to some channels ws.send(JSON.stringify({ //…. some message the I must send when I connect …. })); }; ws.onmessage = function(e) { console.log(‘Message:’, e.data); }; ws.onclose = function(e) { console.log(‘Socket … Read more

Do HTML WebSockets maintain an open connection for each client? Does this scale?

In most ways WebSockets will probably scale better than AJAX/HTML requests. However, that doesn’t mean WebSockets is a replacement for all uses of AJAX/HTML. Each TCP connection in itself consumes very little in terms server resources. Often setting up the connection can be expensive but maintaining an idle connection it is almost free. The first … Read more

Maximum concurrent Socket.IO connections

This article may help you along the way: http://drewww.github.io/socket.io-benchmarking/ I wondered the same question, so I ended up writing a small test (using XHR-polling) to see when the connections started to fail (or fall behind). I found (in my case) that the sockets started acting up at around 1400-1800 concurrent connections. This is a short … Read more

node.js, socket.io with SSL

Use a secure URL for your initial connection, i.e. instead of “http://” use “https://”. If the WebSocket transport is chosen, then Socket.IO should automatically use “wss://” (SSL) for the WebSocket connection too. Update: You can also try creating the connection using the ‘secure’ option: var socket = io.connect(‘https://localhost’, {secure: true});

What is the fundamental difference between WebSockets and pure TCP?

It’s easier to communicate via TCP sockets when you’re working within an intranet boundary, since you likely have control over the machines on that network and can open ports suitable for making the TCP connections. Over the internet, you’re communicating with someone else’s server on the other end. They are extremely unlikely to have any … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)