node.js - Cross-domain socket.io breaks after 30 seconds -
i have simple chat server (node.js/express/socket.io) i'm accessing client on different domain. i've set origins allow everything, has worked. however, after 30 seconds of inactivity client, gets error "xmlhttprequest cannot load [url]. origin not allowed access-control-allow-origin." @ point, can't send messages anymore unless refresh page. i'm allowing origin both io.set('origins', '*:*');
, with
app.all('*', function(req, res, next) { res.header("access-control-allow-origin", "*"); res.header("access-control-allow-headers", "x-requested-with"); next(); });.
i've tried pretty can think of (disabling heartbeats, catching error , reconnecting on client, using io.server.removelistener('request', io.server.listeners('request')[0]);
). know cross-domain problem, because don't have issues when run locally. ideas?
i facing similar issue when working on project use twitter-streaming api chat system. problem facing might due same origin policy (more info here)
also solution found apt cross-domain gif request, concept find used in google analytic script, full explanation of concept can found here.
i hope find useful. did job me.
Comments
Post a Comment