New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
random INVALID_STATE_ERR errors thrown causing program to crash #98
Comments
Do you see this error in node.js caused by |
no I see it in server side sockjs-node here is the trace :
|
This is curious. See this: There are exactly two possibilities: a) @ReadyState is CONNECTING b) it is CLOSED. Both are equally weird. Can you print "@ReadyState" with the error, to figure out which one of those cases occurs? Plus, I need to know which transport is used.. Your traceback suggests XhrPolling. |
I'll add logs to see print readyState and wait for the error to occure (as I said I didn't find a way to reproduce it) we can eliminate the a possibility because there are allways connected players before (this mean that readystate != CONNECTING right ? ) is it possible that this happens with fallback protocoles while XHR polling for example ? |
As an emergency measure, if the Still, I'd like to find a root cause of that. What node are you using btw? Also, are you behind haproxy? |
I added some debug messages to get more information I'll comment back when it happens again. |
Got it ! I reproduced the bug. If the client make an action before xhr timeout a new xhr request is made and the problem does not occure. |
humm after re-reading my comment I'm not sure if it's the client timeout who is causing the server error state or the server error state who is causing the client connection to abort :/ |
Again, are you behind haproxy? Or on heroku maybe? |
I'm behind a varnish proxy... is it a know issue with proxies ? |
No, this traceback is just triggered by network event (TCP.onread in your traceback), so I'd like to know exactly what is your network setup. Which nodejs version? |
I'm using nodejs v0.8.11 |
I must say I have no clue how this traceback can be triggered. Are you running sockjs-node from npm (if so, what version?), or did you build it manually from Aren't you doing something stupid in your code, like manually setting You said you know how to reproduce this traceback, can you explain this in detail? |
I'm using latest sockjs npm version. and I'm not overriding readyState. but when a client log in, he is authentified (using passport module), but hen I need to authenticate sockjs connection, so the client will send a token as a first message, this token is stored in session_id, is this wrong ? do I need to store this token in another field ? the reproduction behaviour is not working I was wrong, but I'm pretty sure it only hapens with fallback protocols, when client support websocket the problem never occure (from my logs). |
Can you elaborate? Can you paste few lines of code that relate to this?
SockJS doesn't really do fallbacks. It establishes a new session every time it tries a new protocol. So from server side the session number is unique and is attached to exactly one transport. |
here is the exact scenario + relevant source code I'm using . here is the code called for authentication. auth.sockjsAuth = function(avatarId, conn, sid, callback) {
var _this=this;
auth.sessionStore.get(sid, function (err, session) {
if (session === undefined) //No session ?
{
Logger.log('sockjs auth failed');
conn.close(401, 'Authentication failed');
return;
}
this.passport.deserializeUser(session.passport.user, function (err, user) {
if (user === undefined) {
Logger.log('sockjs auth failed');
conn.close(401, 'Authentication failed');
return;
}
//Handle anonymous connection
if (user && user.anonymous)
{
Logger.log('Authenticated ', user.id, sid);
conn._session.session_id = sid;
conn._session.userid = user.id;
if (typeof callback == 'function') callback();
return;
}
//Handle authenticated connection
dal.findAvatar(avatarId, user.id, function (err, avatar) {
if (err) {
Logger.log('Authentication error while validating avatarId', err);
conn.close(401, 'Authentication failed');
return;
}
if (avatar)
{
conn._session.session_id = sid;
conn._session.userid = user.id;
if (typeof callback == 'function') callback();
}
});
return;
});
});
} to get a better idea of what I'm doing you can check the online demo using this code here : http://demo.ezelia.com/ |
Okay, this line is very wrong and is causing this traceback.
I'm actually surprised that sockjs-node continues to work at all. Do not touch |
ok I'll modify the code to store the sid in another field. thank you for your help :) btw, I'm using sockjs to write a RMI library (like nowjs) : https://github.com/alaa-eddine/eureca |
Ok, please let me know if modified code works. |
is it ok if I store all my custom values in a subobject ?
|
Hello,
I'm using sockjs for a multiplayer game server, and I'm getting random INVALID_STATE_ERR errors.
I didn't find a test case that reproduce it, seems just to happen randomly.
the problem is that this error is thrown, and I don't know how or where to catch it to prevent server from crashing .
what can cause this error ? and how to catch it ?
The text was updated successfully, but these errors were encountered: