increase timeouts
This commit is contained in:
parent
d14d4a2527
commit
3ae738f453
|
@ -34,8 +34,8 @@ const (
|
|||
defaultSendRate = int64(512000) // 500KB/s
|
||||
defaultRecvRate = int64(512000) // 500KB/s
|
||||
defaultSendTimeout = 10 * time.Second
|
||||
defaultPingInterval = 40 * time.Second
|
||||
defaultPongTimeout = 35 * time.Second
|
||||
defaultPingInterval = 60 * time.Second
|
||||
defaultPongTimeout = 45 * time.Second
|
||||
)
|
||||
|
||||
type receiveCbFunc func(chID byte, msgBytes []byte)
|
||||
|
@ -134,7 +134,7 @@ func NewMConnection(conn net.Conn, chDescs []*ChannelDescriptor, onReceive recei
|
|||
// NewMConnectionWithConfig wraps net.Conn and creates multiplex connection with a config
|
||||
func NewMConnectionWithConfig(conn net.Conn, chDescs []*ChannelDescriptor, onReceive receiveCbFunc, onError errorCbFunc, config *MConnConfig) *MConnection {
|
||||
if config.pongTimeout >= config.pingInterval {
|
||||
panic("pongTimeout must be less than pingInterval")
|
||||
panic("pongTimeout must be less than pingInterval (otherwise, next ping will reset pong timer)")
|
||||
}
|
||||
|
||||
mconn := &MConnection{
|
||||
|
|
|
@ -24,8 +24,8 @@ func createTestMConnection(conn net.Conn) *MConnection {
|
|||
func createMConnectionWithCallbacks(conn net.Conn, onReceive func(chID byte, msgBytes []byte), onError func(r interface{})) *MConnection {
|
||||
chDescs := []*ChannelDescriptor{&ChannelDescriptor{ID: 0x01, Priority: 1, SendQueueCapacity: 1}}
|
||||
cfg := DefaultMConnConfig()
|
||||
cfg.pingInterval = 40 * time.Millisecond
|
||||
cfg.pongTimeout = 35 * time.Millisecond
|
||||
cfg.pingInterval = 60 * time.Millisecond
|
||||
cfg.pongTimeout = 45 * time.Millisecond
|
||||
c := NewMConnectionWithConfig(conn, chDescs, onReceive, onError, cfg)
|
||||
c.SetLogger(log.TestingLogger())
|
||||
return c
|
||||
|
@ -119,7 +119,7 @@ func TestMConnectionStatus(t *testing.T) {
|
|||
assert.Zero(status.Channels[0].SendQueueSize)
|
||||
}
|
||||
|
||||
func TestPongTimeoutResultsInError(t *testing.T) {
|
||||
func TestMConnectionPongTimeoutResultsInError(t *testing.T) {
|
||||
server, client := net.Pipe()
|
||||
defer server.Close()
|
||||
defer client.Close()
|
||||
|
@ -142,7 +142,7 @@ func TestPongTimeoutResultsInError(t *testing.T) {
|
|||
server.Read(make([]byte, 1))
|
||||
}()
|
||||
|
||||
expectErrorAfter := 10*time.Millisecond + mconn.config.pingInterval + mconn.config.pongTimeout
|
||||
expectErrorAfter := (mconn.config.pingInterval + mconn.config.pongTimeout) * 2
|
||||
select {
|
||||
case msgBytes := <-receivedCh:
|
||||
t.Fatalf("Expected error, but got %v", msgBytes)
|
||||
|
|
Loading…
Reference in New Issue