set deadline
Some checks failed
Build and Publish / BuildAndDeployAmd64 (push) Failing after 29s
Build and Publish / BuildAndDeploy (push) Successful in 2m13s

This commit is contained in:
matst80
2024-11-12 13:02:06 +01:00
parent edd4913ebd
commit b44b31307b
2 changed files with 5 additions and 2 deletions

View File

@@ -62,6 +62,7 @@ func (m *CartTCPClient) Connect() error {
func (m *CartTCPClient) SendPacket(messageType uint32, id CartId, data []byte) error {
err := m.Connect()
if err != nil {
return err
}
@@ -75,6 +76,7 @@ func (m *CartTCPClient) SendPacket(messageType uint32, id CartId, data []byte) e
return err
}
_, err = m.Conn.Write(data)
m.Conn.SetDeadline(time.Now().Add(time.Second * 10))
return err
}
@@ -95,7 +97,7 @@ func (m *CartTCPClient) Call(messageType uint32, id CartId, responseType uint32,
select {
case ret := <-packetChan:
return &ret, nil
case <-time.After(time.Second):
case <-time.After(time.Second * 10):
return nil, fmt.Errorf("timeout")
}
}

View File

@@ -81,6 +81,7 @@ func (m *TCPClient) SendPacket(messageType uint32, data []byte) error {
return m.HandleConnectionError(err)
}
_, err = m.Conn.Write(data)
m.Conn.SetDeadline(time.Now().Add(time.Second * 10))
return m.HandleConnectionError(err)
}
@@ -102,7 +103,7 @@ func (m *TCPClient) Call(messageType uint32, responseType uint32, data []byte) (
select {
case ret := <-packetChan:
return &ret, nil
case <-time.After(time.Second):
case <-time.After(time.Second * 10):
return nil, fmt.Errorf("timeout")
}
}