-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
{"code":209,"error":"invalid session token"} on v2.2.15 #2255
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
Comments
Can you run with VERBOSE=1 and provide the logs you see with 2.2.15? |
same here, had to downgrade back to 2.2.3 |
@nirco123 can you provide the server logs when running with VERBOSE=1? We've added a more aggressive checking on invalid session tokens, so whenever a session token is provided, if it's invalid, you'll have that error. The logs may help us understand what's the issue |
@flovilmart I was getting |
I would need the logs related to that call, the ones resulting in an invalid session token error |
this is the response i get on console
and no vebose info but if i create a fresh session i get
and when i go back to even v2.2.14 older session works nicely. |
Can you try with 2.2.16? Again, with verbose logs of the error? |
I still get
on v2.2.16 and nothing on verbose |
Still reproduces on 2.2.17. No verbose logs, only the following in console: even for AppOpened web-service
I'm not sure that it's ok to return 400 (or error code = 209) in response for internal Parse methods which are not under developer's control |
Hi, is there an update on this issue. We have just completed our migration from parse.com to our own instance of parse server and have also experienced {"code":209,"error":"invalid session token"} for many users which forces them to log in again. This was never an issue on our parse.com instance. We experienced the issue on the latest version of parse (2.2.17) and have now rolled back to 2.2.7 just to be sure we don't experience the issue on our Live environment. Many Thanks. |
and update on this issue ? or shall I just roll back ? |
this is likely because all your users are still using a non revocable session. If that's the case, all ACL based security cant work, as we don't load the user pre 2.2.17. It was a bug that we would let invalid session tokens go through the requests as we don't support those legacy tokens. I'm working on the upgrade method in order to make the revocable sessions seemlessly upgrade to revocable session when calling the |
So I have a user that has upgraded to a revocable session on previous sdk - session token is
When that user upgrades the app to pointing straight at the new server I get 209 errors. If on that same user I do a full login on the old client I get the following session.
Then when I flip that user to pointing straight at the new server all is good. It's like the upgrade tokens are not valid ?!?! |
they are valid:
Upgrading the session token is unavailable on parse-server, but if you upgrade your users on api.parse.com then flip to parse-server that should be all good. The updgradeSessionToken endpoint is not implemented and the middlewares that verify the session token gets hit before we can send a 404. This is probably why you're seing that behaviour. Like I said, I plan to ship in 2.2.19 the updgradeSessionToekn method on parse-server you you can seamlessly upgrade the users. |
Hi @flovilmart, is there a chance that there's something else going weird here.? I run a cluster of 3x parse servers (2.2.17) pointing towards the same mongodb cluster. parse-server_1 | error: code=209, message=invalid session token
parse-server_1 | error: beforeSave failed for Order for user WUuw1onCFJ:
parse-server_1 | Input: {"salesPerson":{"__type":"Pointer","className":"_User","objectId":"WUuw1onCFJ"},"customer":{"__type":"Pointer","className":"Customer","objectId":"mrNGXnSdAn"},
parse-server_1 | Error: {"code":141,"message":{"code":209,"message":"invalid session token"}} className=Order, triggerType=beforeSave, code=141, code=209, message=invalid session token, user=WUuw1onCFJ
parse-server_1 | error: Error generating response. ParseError {
parse-server_1 | code: 141,
parse-server_1 | message: ParseError { code: 209, message: 'invalid session token' } } code=141, code=209, message=invalid session token I restart the instance and the problem vanishes, would you tell me how to debug it and try to figure out the problem? |
That is what I am doing in both scenarios. These are the logs from my two scenarios on the server
Hence my view that upgrade tokens are not working as I can't see what else I am doing wrong here ? |
Uhm.... that's very very odd, Do you have the full server logs, with request headers? |
No, I don’t, they are in my production env. I have just the ‘info’ level logged.
|
Uhm... I'm not sure, do the request hit the same server or different ones? Does the newly acquired session token starts with |
I am behind a AWS ELB instance, sometimes hit the same, depends on the server load.
|
We do have caching on the user objects per sessionToken but I don't see how it can interfere as when refreshing the session token, the previous entry become unaccessible... |
@flovilmart do you require any more info from me as I have tried with multiple users and they all get error 400 if they are on an upgrade token |
Anything you can provide may help. Upgraded token should work fine. Mostly we need the 'X-Parse-Session-Token', if you post it, obfuscate it. Do they have a 'r:' starting the string? |
In my previous comment I gave the session tokens for both scenarios (see earlier) both have r: starting the string |
Uhh right sorry. If you manage to reproduce it again (1st case, session token is not usable), can you check in the DB if the _Session records match in structure i.e.: the sessionToken stored key is the same as one with a successful login? |
@chrisfoulds see #2646 maybe that will help. Do you want to try it as you have a very nice way to reproduce your issue? |
@flovilmart getting a bit late in the day overhere but will certainly try it out over the weekend and let you know how it goes. I did check the records and they all seem to line up between the servers. I basically have my app with a flipswitch in it now, so after it fails if flip the switch and restart the app to go back to api.parse.com I get straight back in, it's just using that revocable upgrade session on parse-server , yet a login one still works fine. Tried a server rebuild and numerous restarts and keep getting the same. Anyway will try it over the weekend and feedback, I am hopeful as if the upgrade takes places on my server surely it's going to like the output! |
Awesome, thanks for trying it out. Check out the wiki for running Parse-server from a branch, that's a bit complex as the default npm way won't work. Need to submodule, checkout branch, npm link. |
@flovilmart fixed it on my end. Turns out it was a client issue. Apols |
No need to apologize! |
@dwby Could you please what did you fix. We face similar issue in 2.2.24 |
I am also getting this issue. I have 3 instances running and it happened on one of them, the others responded correctly. Strange thing is also that I get this response from a cloud function that doesn't need any authentication (and I do not provide any token in the headers). Also a client issue doesn't seem probable since I did some requests from Postman and got the error. I would love to know what the client issue was still, @dwby. If anyone of you has any idea where to start to investigate this issue, thank you! EDIT: not that a server restart always fixes it. Since you were talking about caching, I will try to have a look there. |
@maximeloizeau @xavierbabu sorry about the late reply. The client issue had nothing to do with Parse Server. It was just an issue with an incorrect string. One of my calls to Parse relies on a stored date value which was not present due to the incorrect string. |
I found the cause of that error, see the referenced issue #3471. Do you think this may be the same problem for you? |
This problem has always happened to me. The only solution to fix this is restarting the server, and it works like charm. |
Any additional information would be welcome. I'm not sure why restarting the server would fix the issue, perhaps a problem with some caching that we do on users and roles |
@RafaRuiz, do you use Parse.User.logIn or Parse.User.become anywhere in your cloud code? Not using those at all fixed it for us. |
@maximeliozeau all yours parse instances are pointing to a redis instance? |
No, we use the default in-memory cache adapter. If you use the two
functions I mentioned, I don't think it matters because there's a caching
done at the Parse SDK level on the server which causes problems.
Florent indicated that you are not supposed to use this two functions on
the server at all.
…On Sun, 26 Feb 2017, 11:31 Flavio Torres, ***@***.***> wrote:
@maximeliozeau all yours parse instances are pointing to a redis instance?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2255 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABbshBDtreNk7lscah2VIf1-RV09U8TRks5rgWKBgaJpZM4JKMJF>
.
|
@maximeloizeau Yes, I use Parse.User.logIn in JS, iOS and Android. @maximeloizeau @flovilmart One more hint: These are the two scenarios it happened:
To help debugging this, is there any way to see the line that threw the error? |
Ok, I started debugging the problem. My version was 2.3.2. It's happening at It seems it was asking to Auth with an existing I've installed 2.3.5 and trying to reproduce by the same steps I've done in 2.3.2 and it's not happening. I will update if it happens again. |
So that means the sessionToken isn't found in the _Session table. Or that multiple session match for the same sessionToken which is very odd. |
I have started getting Looking at their timestamps they are actually pretty weird as they are Not sure whether my investigation is correct but I'm pasting the mongo query with the results below for you to asses:
|
My apologies to the group if this is a dumb question but is there an example somewhere of how to use upgradeToRevocableSession in an iOS client? I can't seem to find anything in the documentation or on StackOverflow. |
@OpConTech not sure if you should use |
@mman you should look into your client code a it seems you're sending out multiple login requests concurrently. |
@mman I'm investigating now, and we apply a limit to the query to get the 1st object, so those concurrent request should be OK. Do you run multiple instances without a distributed cache like REDIS? |
@flovilmart Yes I have nginx doing SSL termination and load balancing to multiple parse instances that are then talking to the mongo cluster. But in my case it was simply a logic bug that the two login requests are sent immediately after each other thus creating two session ids. Limiting the output of the query to accept either session id as valid would work great for my case. |
That's the thing, the output is already limited as it gets the 1st result only. I have 1 sessions created per login call, but subsequent API calls don't fail. I'll investigate further |
If you want to reproduce this you have to call PFUser.loginInBackground twice with the same credentials. I'm using it over the internet. I think the goal is to trigger two parallel mongo _Session.create operations for the same installationId I'm not sure but perhaps calling it twice over localhost parse-server to the localhost mongo will make the first _Session.create so fast that the other will not create new session? |
@flovilmart To clarify: the second login will not fail. The second login is supposed to create new session row for the same instllationId. What fails is any further API call that verifies the sessionId and finds two rows for the same installationId. |
Yeah but it should never return 2 rows, as we apply limit: 1 to the query.
As you can see in your DB, all the sessions are stored, and the code finds the session by sessionToken ( Line 56 in ca286b7
|
Do I understand you right that you are trying to say that the existing code at Line 56 in ca286b7
{sessionToken} criteria?
Correct? |
By the limit: 1 provided:
|
Looking at the condition that leads to throwing the 'invalid session' error again:
I'm really puzzled, because the other part |
yep it's part of parse-server code, that's the main class for handling all queries, heavily tested... I'm baffled too. |
I upgraded parse-server from v2.2.7 to v2.2.15. I started getting {"code":209,"error":"invalid session token"} for all the users who had logged in 2-3 days earlier. when i reverted back to v2.2.7. things started working again. is there an issue with v2.2.15
The text was updated successfully, but these errors were encountered: