You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 11, 2023. It is now read-only.
So, I have a reconnect function on my client, the moment client loses connection to the server, it attempts to connect again. However, I noticed that if I close the server using .close(), the client gets disconnected (therefore it attempts to connect again) and it can connect again, then it gets disconnected a second time and isn't able to connect again. My conclusion is that there is some time between the clients getting disconnected and the server getting closed. I would solve this by adding some kind of a check on a connection attempt, whether the server is closing.
Here is a log from the client with added commentary, to better understand what is going on:
[22:10:21] [18:24:38:464] [main] [Client/<init>:17] [INFO] Starting door sensor client on Windows 10
[22:10:21] [18:24:38:479] [main] [Client/<init>:19] [INFO] Initializing network system
[22:10:21] [18:24:38:485] [main] [ReconnectableClient/attemptConnect:72] [INFO] Connecting to 192.168.1.15
[22:10:21] [18:24:39:501] [main] [ReconnectableClient/beginConnect:56] [INFO] Successfully connected on 1 attempt //Client connects to the server
[22:10:21] [18:24:39:502] [main] [Client/<init>:23] [INFO] Network system initialized
[22:10:21] [18:24:39:503] [main] [Client/<init>:25] [INFO] Door sensor client started
[22:10:21] [18:25:00:678] [nioEventLoopGroup-2-1] [SessionListener/disconnected:27] [WARN] Got disconnected from the server, attempting reconnect; reason: Server closed //Server#close is called, the client gets disconnected
[22:10:21] [18:25:00:679] [nioEventLoopGroup-2-1] [ReconnectableClient/attemptConnect:72] [INFO] Connecting to 192.168.1.15 //Immediatelly attempts to reconnect
[22:10:21] [18:25:00:716] [nioEventLoopGroup-2-1] [ReconnectableClient/beginConnect:56] [INFO] Successfully connected on 1 attempt //Is able to connect again, even though the server is shutting down
[22:10:21] [18:25:00:769] [nioEventLoopGroup-3-1] [SessionListener/disconnected:27] [WARN] Got disconnected from the server, attempting reconnect; reason: Connection closed. //Gets disconnected the second time, unable to connect again
So, I have a reconnect function on my client, the moment client loses connection to the server, it attempts to connect again. However, I noticed that if I close the server using .close(), the client gets disconnected (therefore it attempts to connect again) and it can connect again, then it gets disconnected a second time and isn't able to connect again. My conclusion is that there is some time between the clients getting disconnected and the server getting closed. I would solve this by adding some kind of a check on a connection attempt, whether the server is closing.
Here is a log from the client with added commentary, to better understand what is going on: