Login method returns UPDATE but no RESULT
Our Unity app connects to a Meteor server via DDP, so we had to roll our own DDP protocol implementation, based on an old library by Greencoder. It works fine, but we are facing an odd behavior of the login method (with a resume token) if we re-connect the app after the user put it in the background and back (the WebSocket connection has to be re-established as well). In this case, quite often we only receive an UPDATED message, but not the RESULT message confirming the login. This happens more often on Android than on iOS.
We're wondering what the reason for this is and if there is a workaround? When experimenting with the setup, we noticed that it works more reliably if we logout explicitly immediately before logging in again. However, it's not 100% reliable, so it's not really a solution.
BTW: We also noticed that if we do call logout immediately before the login, the Meteor server won't always remove the login token from the database as it normally would. If we try the same in the regular Meteor frontend, the token will be removed reliably. The web frontend also never showed the problem that RESULT was not sent on login (we debugged this using the Meteor Dev Tools). We only see this odd behavior in our Unity app.
Meteor version: 1.10.2
Perhaps you have a long running function on the server involving async code that never resolves. Have you tried removing any custom onLogin handlers you might have on the server?
Hi! I'm one of the program coordinators of a nonprofit program called CodeDay Init, and we partner with colleges to help CS students make their first open-source contribution.
We'll claim this issue for now and a group of students will be on it soon with mentorship! If this issue is no longer relevant, please let me know.
Wow, that’s cool. Yes, this issue is still relevant.
Hi @derwaldgeist, This is Sriparna, a student who is working with the codeday team along with Logan Bates. It appears to us that you implemented your own DDP protocol, since you wrote "so we had to roll our own DDP protocol implementation, based on an old library by Greencoder. It works fine, but we are facing an odd behavior of the login method (with a resume token).." Did you check if backward compatibility was an issue? Can you please point us to your repository that hosts the relevant DDP code implementation? Thanks!
Hey @majumdarsr, Thanks for reaching out. Yes, we implemented our own DDP protocol, because we're using Unity as a client instead of a web app.
Did you check if backward compatibility was an issue?
What exactly do you mean my that?
Can you please point us to your repository that hosts the relevant DDP code implementation?
This is the original version from Greencoder: https://github.com/green-coder/unity3d-ddp-client
You should be able to reproduce the problem with this code.
Our fork is here:
https://github.com/derwaldgeist/unity3d-ddp-client
But we haven't updated it for a while. The actual current implementation is not in this repo, since we patched it quite a bit in the meantime to care for other bugs, and this code is in a private repo.
However, the issue at hand is not affected by these later changes. The issue should appear even in the Greencoder version.
@derwaldgeist just to check have you tried it with more recent versions of Meteor, or are you still using 1.10?
I am on 2.2.1 right now.
Hi @derwaldgeist, My name is Logan, Im working with Sriparna and the CodeDay team to resolve this issue but we are in need of some clarification. We have separated your issue into two distinct problems,
#1: Login method with resume token - When app is put in background and back, Updated message is received but not the Result message. Expected behavior: Login with resume token returns Result message and Updated message.
#2: Logout - When logout is called immediately before login, Meteor server will not aways remove the login token from the database. Expected behavior: Meteor server removes login token on logout.
Clarifications:
- Since you are using Unity as a client instead of a web app, and you stated that these issues do not appear in the "web frontend", will we need our own Unity app to test the behaviors of the login and logout functions, or is it possible to recreate these issues using only the green-coder library provided?
- For issue 2: Logout, - Where are you calling logout immediately before login? - What does the term "Meteor Server" reference? (we assumed it meant the code relevant for data manipulation within mongoDB) - What does the term "regular Meteor Frontend" reference? - What database do you expect the Meteor Server to remove the login token from? - Why do you expect the token to be removed from the database? (In researching meteor, we found Meteor wants to keep the login token in the mongoDB to compare and approve login tokens of future logins)
Thank you for all your support!
Hi @derwaldgeist,
Here is what I see when I try to login and reconnect (after brief disconnect, to simulate websocket connection reestablishment) from a web App, built using REACT tutorial and meteor developer version 2.5.6.
Thanks!
Thanks for the update. I never noticed the issue when testing with web app built with Meteor. It only occurs if you connect to the server via DDP directly, using the low-level protocol (in my case, inside a Unity client).
Hi @derwaldgeist, Could you provide a Unity project that will reproduce this problem for us?
Hi @derwaldgeist, if you can share some snapshots of your reported issue, that would be great too. Best,
Hi @derwaldgeist, I am here to update you about what we found about your reported issues.
- Issue#1 "..we are facing an odd behavior of the login method (with a resume token) if we re-connect the app after the user put it in the background and back (the WebSocket connection has to be re-established as well), quite often we only receive an UPDATED message, but not the RESULT message confirming the login. This happens more often on Android than on iOS.."
This issue is reproducible at a shorter timescale in every app built on meteor framework, browser based or otherwise. For ensuring a faster and seamless experience, the desired behavior of meteor is to ignore resume request (or “do nothing”) that arrived within 30 sec after effective websocket disconnect. Please check here.
You have expectedly noticed this more often in unity as unity clients make 100 retries to keep the connection alive, before quitting. Please check here. Android OS is known to be more power intensive for their inefficient management of background apps. Please check here. Thus “effective websocket disconnect time” in android is much shorter than that appears to be.
Hence your 1st issue, while valid, is a desired feature per meteor documentation.
- Issue#2 " ...We also noticed that if we do call logout immediately before the login, the Meteor server won't always remove the login token from the database as it normally would..."
This issue is more related to unity3d-DDP-Client and is not arising due to a bug in meteor. Logan and I are working to patch this issue.
Best, Sri
Hi @derwaldgeist, I have submitted a pull request to your repository, addressing #2 issue discussed above. https://github.com/derwaldgeist/unity3d-ddp-client/pull/1 Best, Sri
It's been pretty cool to see this unfold!