While i'm changing connection, my app crashes and shows the following stacktrace:
E/AndroidRuntime: FATAL EXCEPTION: Timer-3
Process: com.app.teemchat, PID: 9383
io.deepstream.DeepstreamException: CONNECTION_ERROR: null
at io.deepstream.DeepstreamClientAbstract.onError(DeepstreamClientAbstract.java:59)
at io.deepstream.Connection$1.run(Connection.java:187)
at java.util.TimerThread.mainLoop(Timer.java:555)
at java.util.TimerThread.run(Timer.java:505)
Please help me to solve this problem...
client.addConnectionChangeListener(new ConnectionStateListener() {
@Override
public void connectionStateChanged(ConnectionState connectionState) throws RuntimeException {
Log.w(Tag, "ConnectionChange>>> " + connectionState.toString());
if (connectionState.toString().equalsIgnoreCase(ConnectionState.ERROR.toString())) {
client.close();
doLogin();
}
if (connectionState.toString().equalsIgnoreCase(ConnectionState.CLOSED.toString())) {
doLogin();
}
}
});
AlexBHarley says that you need to add setRuntimeErrorHandler
https://github.com/deepstreamIO/deepstream.io-client-java/issues/85
this is expected in the sense that the connection has died, so there is a CONNECTION_ERROR. If you don't want this to throw an exception you can put a listener on the error event with client.setRuntimeErrorHandler. Admittedly the reason could be better than null. The current approach is either one of two things,
infinite reconnect attempts store some local state and restart the session when internet connectivity comes back. We're hoping to tackle some better offline first functionality with resuming sessions and the like, in the near future.