gateio / gatews

Gate Websocket V4 SDK
89 stars 35 forks source link

永续合约websocket断开太频繁 #34

Closed memetea closed 1 year ago

memetea commented 2 years ago

我在testnet订阅了futures.orders和futures.usertrades私有channel。 websocket断开重连的频率太高。 这是testnet的问题, 还是正式环境也一样?
这种断开重连期间发生的事件无法收到, 处理起来挺麻烦的。 有什么好的处理方式吗?

revilwang commented 2 years ago

访问客户端的网络环境是什么样的?具体的订阅参数可以提供下吗?

memetea commented 2 years ago

我用的是golang版本的websocket sdk, 合约为BTC_USDT。 订阅代码如下(userid是我账户的uid):

if err := g.futuresWs.Subscribe(gate.ChannelFutureOrder, []string{"userid", "!all"}); err != nil {
        return nil, err
    }
    if err := g.futuresWs.Subscribe(gate.ChannelFutureUserTrade, []string{"userid", "!all"}); err != nil {
        return nil, err
    }

控制台输出 websocket err:websocket: close 1006 (abnormal closure): unexpected EOF reconnect channel[futures.orders] with payload[[userid!all]] success reconnect channel[futures.usertrades] with payload[[userid!all]] success reconnect success, continue read message

网络是hk的vps主机。 相同网络环境下, binance的websocket就没有断开过。 我自己没有发送ping消息给服务器, 是不是这个原因呢?

revilwang commented 2 years ago

嗯,正常不用自己发 ping ,ws 底层通讯协议能保障,另外 gatews 自己也会处理这个 ping 发送的事情,这个我们检查下

revilwang commented 2 years ago

现在默认 ws 双方都没有任何消息更新超过 1m 会触发一个自动断开,我们今明天更新一下 gatews go 的版本,增加一个定时发送futures.ping 消息,防止被服务端超过 1m 没消息给断开

memetea commented 2 years ago

嗯, 谢谢, 那到时我更新一下试试看

revilwang @.***> 于2022年8月11日周四 11:44写道:

现在默认 ws 双方都没有任何消息更新超过 1m 会触发一个自动断开,我们今明天更新一下 gatews go 的版本,增加一个定时发送 futures.ping 消息,防止被服务端超过 1m 没消息给断开

— Reply to this email directly, view it on GitHub https://github.com/gateio/gatews/issues/34#issuecomment-1211523019, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA6OTVG4EVCTDGQKHRVHFZLVYRZK7ANCNFSM56C2UKNQ . You are receiving this because you authored the thread.Message ID: @.***>

revilwang commented 2 years ago

可以更新最新的 v0.2.7 版本,已经增加该功能的支持