centrifugal / centrifugal/centrifuge-java
Connection restoration error with Centrifuge: Infinite delay during reconnection
- Dominant language
- Java
- Stars
- 76
- Forks
- 38
- Avg merge
- 4h 18m
- Merged PRs (30d)
- 10
Description
Good afternoon,
When the client's connection to Centrifuge is starting to restore, we receive events onSubscribing, then onConnecting, but the connection doesn’t actually restore and no further events occur.
Attaching the client code in Kotlin: https://gist.github.com/Al-exec-V/67bee2798b0795c65f63e38402d4d681
Steps to reproduce:
1. Initialize the client:
val server: HplcCloudWsClient = HplcCloudWsClient(uri, hardwareTokenManager, socketMessageListener, deviceSerial)
2. Call the server.start() method: connect to Centrifuge and subscribe to channels.
- Client and server exchange messages.
3. Switch the internet connection on the device running the client from Ethernet to Wi-Fi.
Scenario 1: The connection is restored, but before that, we receive an onError event with the message "Socket closed."
1. Centrifuge: onSubscribing, client.state=CONNECTING
2. Centrifuge: onConnecting, event.code=2, client.state=CONNECTING
3. Centrifuge: onError, client.state=CONNECTING, event.error.message=Socket closed
4. Centrifuge: onConnected, client.state=CONNECTED
5. Centrifuge: onSubscribed, event.recovered=true, event.wasRecovering=true, client.state=CONNECTED
Scenario 2 (problematic): The connection is not restored, and we do not receive any further events.
1. Centrifuge: onSubscribing, client.state=CONNECTING
2. Centrifuge: onConnecting, event.code=2, client.state=CONNECTING
... waiting ...
Additional details:
- The server is working correctly.
- The client runs in a Docker container on a Raspberry Pi.
- The error occurs when switching the internet connection on the Raspberry Pi from Ethernet to Wi-Fi.
- The internet connection on the device is available after switching as it can be accessed and verified.
- We have not identified any patterns yet. Both Scenario 1 and Scenario 2 occur randomly under the same conditions.
We use the library io.github.centrifugal:centrifuge-java:0.4.1.
Why might there be such a delay in reconnection and an error in restoring the connection?
Thanks in advance for your help
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the attached Kotlin client code and the centrifuge-java 0.4.1 reconnection behavior. Reproduce the Ethernet-to-Wi-Fi switch on the Raspberry Pi Docker setup while tracing onSubscribing, onConnecting, onError, onConnected, and onSubscribed. Done means identifying the cause of the stalled restoration or documenting the conditions and expected reconnection behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, java
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100