Skip to content
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

4.22 Reconnection bug #126

Closed
lwglwg opened this issue Jun 4, 2019 · 21 comments
Closed

4.22 Reconnection bug #126

lwglwg opened this issue Jun 4, 2019 · 21 comments

Comments

@lwglwg
Copy link

lwglwg commented Jun 4, 2019

Disconnect WIFI and connect WIFI, and the SOCKET will automatically disconnect and reconnect

[2019.06.04-14.36.04:118][954]SocketIOLog: SocketIO KwYBgdagAE1scUqPAAA9 appears to have lost connection, reconnecting attempt 1 with delay 7500
[2019.06.04-14.36.04:118][954]LogTemp: OnConnectionProblems
[2019.06.04-14.36.35:849][218]SocketIOLog: SocketIO Connected with session: glZR4NHG_xAdkwMHAAA-
[2019.06.04-14.36.35:849][218]LogTemp: OnConnectedCallback
[2019.06.04-14.36.35:849][218]SocketIOLog: SocketIO glZR4NHG_xAdkwMHAAA- connected to namespace: /
[2019.06.04-14.36.35:850][218]LogTemp: OnNamespaceConnectedCallback
[2019.06.04-14.37.08:742][381]SocketIOLog: SocketIO glZR4NHG_xAdkwMHAAA- appears to have lost connection, reconnecting attempt 0 with delay 5000
[2019.06.04-14.37.08:742][381]LogTemp: OnConnectionProblems
The thread 0x66c has exited with code 0 (0x0).
[2019.06.04-14.37.29:710][545]SocketIOLog: SocketIO Connected with session: zU7SbpnESy8mwstMAAA_
[2019.06.04-14.37.29:710][545]LogTemp: OnConnectedCallback
[2019.06.04-14.37.29:710][545]SocketIOLog: SocketIO zU7SbpnESy8mwstMAAA_ connected to namespace: /
[2019.06.04-14.37.29:711][545]LogTemp: OnNamespaceConnectedCallback
The thread 0x423c has exited with code 0 (0x0).
[2019.06.04-14.38.06:849][709]SocketIOLog: SocketIO zU7SbpnESy8mwstMAAA_ appears to have lost connection, reconnecting attempt 0 with delay 5000
[2019.06.04-14.38.06:850][709]LogTemp: OnConnectionProblems
[2019.06.04-14.38.33:160][873]SocketIOLog: SocketIO Connected with session: kPvNI97Vq3apOZJGAABA
[2019.06.04-14.38.33:160][873]LogTemp: OnConnectedCallback
[2019.06.04-14.38.33:160][873]SocketIOLog: SocketIO kPvNI97Vq3apOZJGAABA connected to namespace: /
[2019.06.04-14.38.33:160][873]LogTemp: OnNamespaceConnectedCallback
[2019.06.04-14.40.52:789][ 37]SocketIOLog: SocketIO kPvNI97Vq3apOZJGAABA appears to have lost connection, reconnecting attempt 0 with delay 5000
[2019.06.04-14.40.52:789][ 37]LogTemp: OnConnectionProblems

@getnamo
Copy link
Owner

getnamo commented Jun 16, 2019

likely a bug in https://github.com/getnamo/socket.io-client-cpp/tree/non-boost not using reliable close, to be investigated

@getnamo
Copy link
Owner

getnamo commented Jul 1, 2019

potential fix in 8bf27c6

@getnamo getnamo changed the title 4.22bug 4.22 Re-connection bug Jul 1, 2019
@getnamo getnamo changed the title 4.22 Re-connection bug 4.22 Reconnection bug Jul 1, 2019
@getnamo
Copy link
Owner

getnamo commented Jul 1, 2019

possibly related problem: #122

@lwglwg
Copy link
Author

lwglwg commented Jul 2, 2019

This BUG was not fixed successfully, I still have this problem after testing in the editor.
bug

@lwglwg
Copy link
Author

lwglwg commented Jul 2, 2019

bug2
You can test the network reconnection BUG by disabling and turning on the network connection

@aam-git
Copy link

aam-git commented Jul 6, 2019

I also have this bug.

If the server disconnects unexpectedly, this client reconnects fine, however it then disconnects 5 seconds later (or whatever i set "Reconnection Delay in Ms" to) and then reconnects in a infinite loop, it's almost as if the reconnect code doesn't know there is already a connection re-established.

@getnamo
Copy link
Owner

getnamo commented Jul 7, 2019

Ok this doesn't happen on localhost connections, but it will appear if you use direct ip/external networking. I can now replicate this and will look into root cause.

@getnamo
Copy link
Owner

getnamo commented Jul 7, 2019

Temp fix:
Use an earlier v0.xx version e.g. https://github.com/getnamo/socketio-client-ue4/releases/tag/0.10.0. Only new compile-in-module architecture suffers from this bug.

Note to self:
The 4.21 v0.10.0 does not have this problem. Appears to be a regression from re-architecture for multi-platform support. Check websocket backend diff. This problem seems to behave similarly to old #29, possibly fixed in https://github.com/getnamo/socketio-client-ue4/commits/0.5.0, likely getnamo/socket.io-client-cpp@1d6a0ec and getnamo/socket.io-client-cpp@73a1047

Update: The above fixes do appear already embedded and not enough. Likely due to change to WS 0.8.1

@lwglwg
Copy link
Author

lwglwg commented Jul 7, 2019

Please fix it as soon as possible. Thank you very much!

@lwglwg
Copy link
Author

lwglwg commented Jul 7, 2019

Currently my game runs on android, and the old version doesn't work

@getnamo
Copy link
Owner

getnamo commented Aug 16, 2019

note to self:

@Wadimich
Copy link

Wadimich commented Sep 4, 2019

I have encountered this too.

Looked at the code, i've negated IF condition on
\SocketIOClient\Source\SocketIOLib\Private\internal\sio_client_impl.cpp:323.

Now any connection problems are resolved. It still times out if there is connection problems, it does not reconnect every 5 secs after successful reconnection.

@getnamo please take a look.

I think a man who code this just did some Ctrl+C Ctrl+V mistake.

@getnamo
Copy link
Owner

getnamo commented Sep 4, 2019

It's a bit more complicated than that. Having a ping timeout is a good thing to detect connection problems with your server, but for some reason re-connecting doesn't seem to reset the timeout. Looking for a bit more dev time to address this properly.

A temporary fix either your suggestion or commenting out https://github.com/getnamo/socketio-client-ue4/blob/master/Source/SocketIOLib/Private/internal/sio_client_impl.cpp#L339 which will stop the timeout from closing your connection.

@Wadimich
Copy link

Wadimich commented Sep 4, 2019

I did some tests, and all timeouts were working properly. Maybe i'm not understand something?

@getnamo
Copy link
Owner

getnamo commented Sep 4, 2019

I think I misread your earlier comment. You do appear to be correct :) ! It does seem to fix it. It's funny how you can look at the same code often and just skim over parts with mental assumptions.

I'll do some tests and merge the fix once they're done.

Great spot 👍

@getnamo
Copy link
Owner

getnamo commented Sep 4, 2019

fix merged into dev-unstable here: 3984f34

Will cleanup some more issues before making a new release

@getnamo
Copy link
Owner

getnamo commented Sep 5, 2019

Note to self: looking at past states, the above fix is still not 'proper'. Old v0.10 had the old https://github.com/getnamo/socketio-client-ue4/blob/master/Source/SocketIOLib/Private/internal/sio_client_impl.cpp#L323 setting without the associated bug. It's likely system timer reset behaves differently from boost version. The workaround does however address the issue with minimal side effects (one alloc per ping). Should test moving reallocation to same place as ping timer and what error codes do

getnamo added a commit that referenced this issue Sep 5, 2019
- to track solution 2 in history
@getnamo
Copy link
Owner

getnamo commented Sep 5, 2019

Different solution posted under e2f6522. I suspect you can't cancel() and re-schedule a timer synchronously as you could in boost. I've opted to just cancel the timeout timer on the first message received after pinging https://github.com/getnamo/socketio-client-ue4/blob/e2f65228a44bfdd5dae7372049a3f283c55b6e26/Source/SocketIOLib/Private/internal/sio_client_impl.cpp#L502 which is the correct behavior. On ping interval it will re-schedule the timeout event correctly if the timeout timer has been reset, functionality remains without needing a re-allocation per message received.

Tested and confirmed stability on win64. Will require tests on other platforms along with other changes for v1.1.0 release.

@getnamo
Copy link
Owner

getnamo commented Sep 5, 2019

Updated the early release with the fix which can be found here: https://github.com/getnamo/socketio-client-ue4/releases/tag/v1.1.0e(1.0.24)

Let me know if this fix works for anyone having the problem.

@Wadimich
Copy link

Wadimich commented Sep 7, 2019

Testing this one. It does not reconnects each time for now. Tested on Win64 and Ubuntu 18.04

@getnamo
Copy link
Owner

getnamo commented Sep 12, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants