简体   繁体   English

使用 deepstream 更改连接时应用程序崩溃

[英]App crashes on connection change using deepstream

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 AlexBHarley 说你需要添加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.这是预期的连接已经死亡,所以有一个 CONNECTION_ERROR。 If you don't want this to throw an exception you can put a listener on the error event with client.setRuntimeErrorHandler.如果您不希望这引发异常,您可以使用 client.setRuntimeErrorHandler 在错误事件上放置一个侦听器。 Admittedly the reason could be better than null.不可否认,原因可能比 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.我们希望在不久的将来通过恢复会话等来解决一些更好的离线优先功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM