Jitendra Pawar Jitendra Pawar - 2 months ago 18
Node.js Question

Socket.io disconnects after certain time interval

We have created a real time chat application, with a socket.io, nodejs & mongodb. It is working fine on to a local & modulus server, but not working as expected on AWS.

Socket gets disconnected randomly with a ping timeout after around 60 sec. I also set "Heart Timeout" & "Heart Interval" but still it gets disconnected.

Here is the attached config file for node,

var config = {
local : {
mode : "LOCAL",
port : 8080,
db_path : "mongodb://localhost/local_db",
site_loc : "http://dummy.local/",
api_loc : "http://dummy.dummy.com/"
},
dev : {
mode : "DEV",
port : 8080,
db_path : "mongodb://dbath:27017/dev_db",
site_loc : 'http://dummy.dummy.com/',
api_loc : 'http://dummy.dummy.com/'
},
stage : {
mode : "STAGE",
port : 3000,
db_path : "mongodb://localhost:27017/stage_db",
site_loc : 'http://dummy.dummy.com/',
api_loc : 'http://dummy.dummy.com/'
},
production : {
mode : "PROD",
port : 443,
db_path : "mongodb://localhost:27017/live_db",
site_loc : 'https://dummy.com/',
api_loc : 'https://dummy.dummy.com/'
}
}

module.exports = function(mode) {
return config[mode || process.argv[2]] || config.local;
}

Answer

I resolved this issue, by just adding a port number besides link like,

http://www.chat.com:3000/

by d way thanks everyone...

Comments