troyzhxu/okhttps

stomp连接时发生服务端异常,重连过程中异常,导致stomp状态异常

Closed this issue · 1 comments

 public synchronized Stomp connect(List<Header> headers) {
        if (connected || connecting) {
            return this;
        }
        websocket = task
            .setOnOpen((ws, res) -> doOnOpened(headers))
            .setOnMessage((ws, msg) -> msgCodec.decode(msg.toString(), this::receive))
            .setOnException((ws, e) -> doOnException(e))
            .setOnClosed((ws, close) -> doOnClosed(close))
            .listen();
        connecting = true;
        disconnecting = false;
        return this;
    }

断点发现一个问题,
1.正常运行状态下,断开服务器,会调用onclosed
2.断开立马进行重连,会回调onexception报服务器502错误,connecting被设置成false
3.稍后再次进行stomp.connect() 服务器还没有重启好 connecting被设置成了true,然后onexception也不回调,导致connecting一直是true,然后connect的时候一直return this 无法重新连接