delight-im / delight-im/Android-DDP
Client connections when internet lost
- Dominant language
- Java
- Stars
- 274
- Forks
- 51
- PR merge metrics
- No merged PRs in 30d
Description
Hi there, I have found an issue.
I am trying to handle all my internet connections handlers, reconnections and disconnections. The meteor handlers works just find OnDiscconnected and onException etc.
My approach right now to reconnect once the internet is back (without having a broadcast from android telling me the internet state). Is the next one:
`
@Override
public void onDisconnect() {
Log.e("gotDisconnected","well...");
mMeteor.reconnect();
}
`
and it works well, it gets reconnect but the problem is that all web sockets that tried to connect while the internet was off are getting connected.
```
/**
* Opens a connection to the server over websocket
*
* @param isReconnect whether this is a re-connect attempt or not
*/
private void openConnection(final boolean isReconnect) {
if (isReconnect) {
if (mConnected) {
initConnection(mSessionID);
return;
}
}
// create a new WebSocket connection for the data transfer
mWebSocket = new WebSocket(URI.create(mServerUri));
// attach the handler to the connection
mWebSocket.setEventHandler(mWebSocketEventHandler);
try {
mWebSocket.connect();
}
catch (WebSocketException e) {
mCallbackProxy.onException(e);
}
}
```
first I saw at my galaxy dashboard that my server was getting 100+ clients when I'm the only one running tests. Then on my log I found a lot of exceptions after my internet was reestablished.
```
:remote E/METEOR EXCEPTION: unknown host: wagen.meteorapp.com
:remote E/gotDisconnected: well...
:remote E/METEOR EXCEPTION: error while sending data: not connected
:remote E/data removed: kadira_settings
:remote E/info: {"emails":[{"address":"some@email.com","verified":true}],"profile":{"name":"Carlos Palmero","type":"Driver","boss":"p4QQGew7EqbYr4TWg","connection":true,"currentStatus":1,"statusStack":[{"status":{"name":"Solving Ticket","description":"When the driver has arrived and start doing the service","color":"#6600cc"},"timeStamp":{"$date":1463417312821}},{"status":{"name":"On Service","description":"When the driver has started his service","color":"#00ff00"},"timeStamp":{"$date":1463418509087}},{"status":{"name":"Solving Ticket","description":"When the driver has arrived and start doing the service","color":"#6600cc"},"timeStamp":{"$date":1463422746940}}]}}
:remote E/gotConnected: is signed in?yep
:remote E/data removed: kadira_settings
:remote E/METEOR EXCEPTION: IO Error
:remote E/gotDisconnected: well...
:remote E/METEOR EXCEPTION: IO Exception
:remote E/data removed: kadira_settings
:remote E/info: {"emails":[{"address":"some@email.com","verified":true}],"profile":{"name":"Carlos Palmero","type":"Driver","boss":"p4QQGew7EqbYr4TWg","connection":true,"currentStatus":1,"statusStack":[{"status":{"name":"Solving Ticket","description":"When the driver has arrived and start doing the service","color":"#6600cc"},"timeStamp":{"$date":1463417312821}},{"status":{"name":"On Service","description":"When the driver has started his service","color":"#00ff00"},"timeStamp":{"$date":1463418509087}},{"status":{"name":"Solving Ticket","description":"When the driver has arrived and start doing the service","color":"#6600cc"},"timeStamp":{"$date":1463422746940}}]}}
:remote E/gotConnected: is signed in?yep
:remote E/data removed: kadira_settings
:remote E/gotDisconnected: well...
:remote E/METEOR EXCEPTION: error while sending data: not connected
:remote E/data removed: kadira_settings
:remote E/info: {"emails":[{"address":"some@email.com","verified":true}],"profile":{"name":"Carlos Palmero","type":"Driver","boss":"p4QQGew7EqbYr4TWg","connection":true,"currentStatus":1,"statusStack":[{"status":{"name":"Solving Ticket","description":"When the driver has arrived and start doing the service","color":"#6600cc"},"timeStamp":{"$date":1463417312821}},{"status":{"name":"On Service","description":"When the driver has started his service","color":"#00ff00"},"timeStamp":{"$date":1463418509087}},{"status":{"name":"Solving Ticket","description":"When the driver has arrived and start doing the service","color":"#6600cc"},"timeStamp":{"$date":1463422746940}}]}}
:remote E/gotConnected: is signed in?yep
:remote E/data removed: kadira_settings
```
and after I force quit it this displayed at Log:
```
E/METEOR EXCEPTION: Connection closed before handshake was complete
```
a lot of times btw
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the onDisconnect handler and the private openConnection method shown in the issue, then reproduce the behavior by disabling and restoring internet access. Trace how failed WebSocket attempts are retained or reopened; done means restoring connectivity does not create duplicate client connections or repeated not-connected and handshake exceptions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java
- Domain
- mobile-dev, networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100