openim-sdk-core icon indicating copy to clipboard operation
openim-sdk-core copied to clipboard

[Other]: Sending failure will lock for 63 seconds

Open yupor5 opened this issue 1 year ago • 3 comments

What would you like to share?

Sending failure will lock for 63 seconds

func (c *LongConnMgr) sendAndWaitResp(msg *GeneralWsReq) (*GeneralWsResp, error) { tempChan, err := c.writeBinaryMsgAndRetry(msg) defer c.Syncer.DelCh(msg.MsgIncr) if err != nil { return nil, err } else { select { case resp := <-tempChan: return resp, nil case <-time.After(time.Second * 3): return nil, sdkerrs.ErrNetworkTimeOut }

}

}

func (c *LongConnMgr) writeBinaryMsgAndRetry(msg *GeneralWsReq) (chan *GeneralWsResp, error) { msgIncr, tempChan := c.Syncer.AddCh(msg.SendID) msg.MsgIncr = msgIncr if c.GetConnectionStatus() != Connected && msg.ReqIdentifier == constant.GetNewestSeq { return tempChan, sdkerrs.ErrNetwork.Wrap("connection closed,conning...") } for i := 0; i < 60; i++ { err := c.writeBinaryMsg(*msg) if err != nil { log.ZError(c.ctx, "send binary message error", err, "message", msg) c.closedErr = err _ = c.close() time.Sleep(time.Second * 1) continue } else { return tempChan, nil } } return nil, sdkerrs.ErrNetwork.Wrap("send binary message error") }

Additional information

No response

yupor5 avatar Aug 17 '23 06:08 yupor5