Socket.io returns to XHR poll
I have an Express, Node and Socket.io app, when I check the Network I see that the Socket is falling back to XHR reuqests and not WebSockets.
Am I missing something obvious?
In my console, I see that on my Networks tab, I don't see the WebSocket, just XHR requests to socket.io:
WebSocket connection to 'ws://localhost/socket.io/?EIO=3&transport=websocket&sid=lVFuwHcH-XPm8zHhAAAA' failed: Error in connection establishment: net::ERR_SOCKS_CONNECTION_FAILED
Server code:
var app = express(),
http = require('http').Server(app),
io = require('socket.io')(http),
io.on("connection", function (socket) {
var interval = setInterval(function () {
if(nt == ""){
socket.emit("message", {"data": "<strong>Waiting for data...</strong>"});
}else{
socket.emit("data", {
"mediumLoadTime": nt.mediumPageLoad(),
"firstLoadTime": nt.times[0],
"lastLoadTime": nt.times[nt.times.length-1],
//"times": nt.times,
"requests": nt.reqMade.toString(),
"success": nt.successful.toString(),
"error": nt.error.toString(),
"virtualusers": nt.virtualUsers.toString(),
"host": nt.options.host.toString(),
});
}
}, 10);
socket.on("disconnect", function () {
clearInterval(interval);
});
});
Customer:
var socket = io();
socket.on('data', function (data) {
console.log(data);
});
In my opinion, I need <script src="https://cdn.socket.io/socket.io-1.2.0.js"></script>
+3
source to share
No one has answered this question yet
Check out similar questions: