mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 14:55:16 +00:00
fix reconnect close
This commit is contained in:
parent
906350a5bc
commit
a9e25c08d7
|
@ -147,12 +147,20 @@ func (s *PrivateStream) read(ctx context.Context, eventC chan interface{}) {
|
||||||
|
|
||||||
mt, message, err := s.Conn.ReadMessage()
|
mt, message, err := s.Conn.ReadMessage()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WithError(err).Errorf("read error: %s", err.Error())
|
if websocket.IsUnexpectedCloseError(err, websocket.CloseGoingAway) {
|
||||||
|
log.WithError(err).Errorf("read error: %s", err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
// reconnect
|
// reconnect
|
||||||
for err != nil {
|
for err != nil {
|
||||||
err = s.connect(ctx)
|
select {
|
||||||
time.Sleep(5 * time.Second)
|
case <-ctx.Done():
|
||||||
|
return
|
||||||
|
|
||||||
|
default:
|
||||||
|
err = s.connect(ctx)
|
||||||
|
time.Sleep(5 * time.Second)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Reference in New Issue
Block a user