Sleep before first reconnect attempt
This commit is contained in:
parent
530e08b9ee
commit
010bb6a102
@ -6,6 +6,7 @@ import (
|
||||
"net"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/jpillora/backoff"
|
||||
)
|
||||
@ -54,6 +55,8 @@ func NewClient(nick, username string) *Client {
|
||||
reconnect: make(chan struct{}),
|
||||
recvBuf: make([]byte, 0, 4096),
|
||||
backoff: &backoff.Backoff{
|
||||
Min: 500 * time.Millisecond,
|
||||
Max: 30 * time.Second,
|
||||
Jitter: true,
|
||||
},
|
||||
}
|
||||
|
@ -79,6 +79,7 @@ func (c *Client) run() {
|
||||
c.sendRecv.Wait()
|
||||
c.reconnect = make(chan struct{})
|
||||
|
||||
time.Sleep(c.backoff.Duration())
|
||||
c.tryConnect()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user