Skip to content

Commit

Permalink
CloseAndReconnect(): Close WS even if connect goroutine is running
Browse files Browse the repository at this point in the history
  • Loading branch information
ihorserba committed Apr 10, 2021
1 parent c8fd2e5 commit b9c8232
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion recws.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ const (

// CloseAndReconnect will try to reconnect.
func (rc *RecConn) CloseAndReconnect() {
rc.Close()

This comment has been minimized.

Copy link
@vocoded

vocoded Apr 10, 2021

won't this cause problems if IsConnecting is true? seems like this logic should be:

func (rc *RecConn) CloseAndReconnect() {
    rc.Close()
    if rc.IsExiting() {
        return
    }
    go rc.connect()
}

This comment has been minimized.

Copy link
@ihorserba

ihorserba Apr 10, 2021

Author Owner

@vocoded I added this flag by myself in order to fix the original recws issue: recws-org#20

The idea is to have the only connect() goroutine running at the same time.

It's still not fixed in the original repo.

if rc.IsConnecting() || rc.IsExiting() {
return
}
rc.Close()
go rc.connect()
}

Expand Down

0 comments on commit b9c8232

Please sign in to comment.