Failed to load resource: the server responded with a status of 426 (Upgrade Required)
Solution 1
you have to open your index.html in browser not http://127.0.0.1:3434 its a websocket server. You are trying to make a http connection to a websocket server.
Solution 2
Most probably your server socket at localhost:3434 don't have support for websocket, so the connection is terminated by the client browser.
This error indicates that on localhost:3434 you are running a HTTP server which is incapable to "upgrade" to websocket.
(Since both simple http and websocket begins with a simple http request. In that http request the client ask the server to switch to websocket protocol.)
Comments
-
Ismail Rubad almost 2 years
I tried to go with the tutorial of this link http://web-engineering.info/node/57
But when I execute node server.js and open the browser http://localhost:3434 it says upgrade required. The server.js file is:
var WebSocketServer = require('ws').Server, wss = new WebSocketServer({port: 3434}); wss.broadcast = function (data) { var i = 0, n = this.clients ? this.clients.length : 0, client = null; for (; i < n; i++) { client = this.clients[i]; if (client.readyState === client.OPEN) { client.send(data); } else console.error('Error: the client state is ' + client.readyState); } }; wss.on('connection', function (ws) { ws.on('message', function (message) { wss.broadcast(message); }); });