Skip to content

Commit

Permalink
* Updated default ReadTimeout and WriteTimeout to 60 seconds
Browse files Browse the repository at this point in the history
  • Loading branch information
pkcs8 committed Sep 22, 2024
1 parent 0de3c92 commit 473bdf0
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ type ClientConfig struct {
Passphrase byte
Proxy byte
ProxyAuthorization byte
ReadTimeout time.Duration
WriteTimeout time.Duration
HeartbeatInterval time.Duration
QueueCapacity int
ReadTimeout time.Duration // Default is 60 seconds
WriteTimeout time.Duration // Default is 60 seconds
HeartbeatInterval time.Duration // Default is 5 seconds
QueueCapacity int // Default is 128
}

type Client struct {
Expand Down Expand Up @@ -76,10 +76,10 @@ func (config *ClientConfig) Validate() error {

func NewClient(config ClientConfig) *Client {
if config.ReadTimeout == 0 {
config.ReadTimeout = 20
config.ReadTimeout = 60
}
if config.WriteTimeout == 0 {
config.WriteTimeout = 20
config.WriteTimeout = 60
}
if config.HeartbeatInterval == 0 {
config.HeartbeatInterval = 5
Expand Down Expand Up @@ -195,12 +195,12 @@ func (c *Client) Close() error {

err := c.connection.WriteMessage(websocket.CloseMessage, websocket.FormatCloseMessage(websocket.CloseNormalClosure, ""))
if err != nil {
log.Println("WS write error: ", err)
log.Println("WS write error:", err)
return err
}
err = c.connection.Close()
if err != nil {
log.Println("WS close error: ", err)
log.Println("WS close error:", err)
return err
}
return nil
Expand Down

0 comments on commit 473bdf0

Please sign in to comment.