-
-
Notifications
You must be signed in to change notification settings - Fork 597
LiveQuery socket not reconnecting on resume from sleep in mobile #585
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
After debugging further, I've seen that the state is _this4.socket.close();
_this4.resubscribe(); From this, I found that the close would not fire for exactly 1min (I output some timestamps to the HTML). I cannot find where this 1min timeout comes from...any ideas? |
I'm using this to log my findings...hope someone can help:
|
I’m not sure it is related to the JS SDK itself. Perhaps there are workarounds that we could implement. Also, where lis your parse-server deployed? |
I am using Back4App, Parse Server 2.7.1. I agree, I don't think it is an issue with the SDK...I was just using the SDK to debug/hack to try to find a workaround. |
Possibly also related to a seeverside connection configuration. Did you try with a pure JS websocker client without the parse JS SDK? |
I have contacted back4app for some help...awaiting further feedback. I have no idea how to test with a JS websocket client...you mean use something like socket.io to connect to the Parse server and see if I get the same issue? Could you help as to how to do this? |
I'm starting to think it might be my phone or browser!!...not seen the issue on another phone and tablet. |
@dpatel20 that's something to consider too :) |
@flovilmart Seems to be occurring in other browsers and devices (to different extents/frequencies) --- all Android based. With the original code (without my hacks), it eventually seems to kick back into life. Any suggestions of how I can work around this (or reduce the time to reconnect)? |
I’m not sure at this point. Is there littérature around the reconnections problems, like with socketIO or else? |
I have done some more testing and taken logcats on my Android phone and various debug messages added. I can see that the connection is actually closed and the reconnect mechanism kicks in. But then it sits in the 'open' (i.e. trying to re-open the socket) state as there is no network. When I resume the device, it can take a few secs to reconnect but it does reconnect. I was testing fairly soon after unlocking and saw that it was missing the event. If I wait a few seconds and then fire the event, then all is good. |
Ok, good to hear you have a proper explanation!
…On Jun. 22, 2018, 05:37 -0400, dpatel20 ***@***.***>, wrote:
I have done some more testing and taken logcats on my Android phone and various debug messages added. I can see that the connection is actually closed and the reconnect mechanism kicks in. But then it sits in the 'open' (i.e. trying to re-open the socket) state as there is no network.
When I resume the device, it can take a few secs to reconnect but it does reconnect. I was testing fairly soon after unlocking and saw that it was missing the event. If I wait a few seconds and then fire the event, then all is good.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
I should note that I had to reduce the backoff in return Math.random() * k * 2000; With the original setup I had a connection timeout error in the logcat. |
@dpatel20 is the back off configuration worth an addition to the SDK so the issue can be worked around? |
Do you mean being able to pass your own backoff function to the SDK? |
Yep somehow when you setup the liveQuery client |
Hmmm...I'm a bit concerned that maybe a lot more complicated than it first seems (at least to me). The generateInterval() function is not part of the |
Yeah perhaps, my concern is that you’re able to ship something that works, with a potential workaround |
Well, this is frustrating now...I've gone back to the original |
Haha, indeed! |
Should we close this one then? Feel free to reopen if needed |
Agreed...close for now. If I find why I got the timeout error mentioned above, then I'll reopen. |
I have created a Web App use the Parse backend which utilises Parse's LiveQuery (Websockets).
Whilst testing on mobile devices, I have noticed that after a long(ish) sleep the LiveQuery events don't seem to get through. Best as I can tell/understand, the browser is closing (?) the websocket.
Behind the scenes, I know the Parse JS SDK implements an exponential backoff automatic reconnect.
Is there a way to instantly auto connect on the browser window getting focus?
I tried a quick hack in the JS SDK as follows in the LiveQuery 'open' function
However, this does not seem to work (at least not consistently). If I remove the check on the
CONNECTED
status, then it seems to work but then I end up with multiple sockets open (I know as I have a toast popup that is activated on live updates -- without theCONNECT
check I get two popups instead of one). So, does that suggest that the Parse SDK is not aware the connection is broken? How I can I force a check?The text was updated successfully, but these errors were encountered: