troyzhxu / okhttps

如艺术一般优雅,像 1、2、3 一样简单,前后端通用,轻量却强大的 HTTP 客户端(同时支持 WebSocket 与 Stomp 协议)
https://ok.zhxu.cn
Apache License 2.0
487 stars 75 forks source link

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

Closed sanpark closed 2 years ago

sanpark commented 2 years ago
 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 无法重新连接

troyzhxu commented 2 years ago

已在 v3.4.7v3.5.2 中修复: https://github.com/ejlchina/okhttps/releases/tag/v3.4.7 https://github.com/ejlchina/okhttps/releases/tag/v3.5.2