diff --git a/const.go b/const.go index baa29c5..a31a1c5 100644 --- a/const.go +++ b/const.go @@ -1,5 +1,7 @@ package server +import "time" + const ( // DefaultConcurrency is the maximum number of concurrent connections // the Server may serve by default (i.e. if Server.Concurrency isn't set). @@ -23,9 +25,9 @@ const ( // DefaultMaxMessageSize is default size for a message read from the peer DefaultMaxMessageSize = 4096 // DefaultPongTimeout is default value of websocket pong Timeout - DefaultPongTimeout = 0 + DefaultPongTimeout = 60 * time.Second // DefaultPingTimeout is default value of websocket ping Timeout - DefaultPingTimeout = 0 + DefaultPingTimeout = 10 * time.Second // DefaultPingPeriod is default value of send ping period - DefaultPingPeriod = 0 + DefaultPingPeriod = (DefaultPingTimeout * 9) / 10 ) diff --git a/server-handler.go b/server-handler.go index 395aef4..601768b 100644 --- a/server-handler.go +++ b/server-handler.go @@ -183,7 +183,7 @@ func (sh *ServerHandlers) Validate() error { sh.PingTimeout = DefaultPingTimeout } if sh.PingPeriod <= 0 { - sh.PingPeriod = DefaultPingPeriod + sh.PingPeriod = (sh.PingTimeout * 9) / 10 } return nil