node.js - Too many EIO socket.io polling calls slowing the web page -
my application based on socket.io have chat functionality.
my application deployed on red hat open shift.
i keep getting http://url/socket.io/?eio=3&transport=polling&t=lj8hukr&sid=y1ob9obmdsd_ma4naafg requests huge in number.
and blocking loading of web page slowing web page.
i read in internet error comes if port not mentioned. port number coming of red hat open shift configuration page.
below code of how socket.io intialized in initial html page node js initial server page
index.html
var socket =io();
index.js (node js server)
var app = express(); var server = app.listen(process.env.node_port || 3006, process.env.node_ip || 'localhost', function(){ console.log('listening on port 3006'); }); var io = require('socket.io').listen(server); io.on('connection', function(socket) { console.log('a user connected'); socket.on('disconnect', function() { console.log('user disconnected'); }); socket.on('chat message', function(msg) { console.log(msg); io.emit('chat message', msg); });
xhr long polling default connection type socketio client. client upgrade websocket if possible otherwise there request every few seconds polling client.
Comments
Post a Comment