Fix len of write operation

This commit is contained in:
Zoltán Papp 2024-07-22 13:13:12 +02:00
parent 0329c12173
commit 1097285d80
2 changed files with 5 additions and 3 deletions

View File

@ -402,11 +402,13 @@ func (c *Client) writeTo(connReference *Conn, id string, dstID []byte, payload [
log.Errorf("failed to marshal transport message: %s", err) log.Errorf("failed to marshal transport message: %s", err)
return 0, err return 0, err
} }
n, err := c.relayConn.Write(msg)
// the write always return with 0 length because the underling does not support the size feedback.
_, err = c.relayConn.Write(msg)
if err != nil { if err != nil {
log.Errorf("failed to write transport message: %s", err) log.Errorf("failed to write transport message: %s", err)
} }
return n, err return len(payload), err
} }
func (c *Client) listenForStopEvents(hc *healthcheck.Receiver, conn net.Conn, internalStopFlag *internalStopFlag) { func (c *Client) listenForStopEvents(hc *healthcheck.Receiver, conn net.Conn, internalStopFlag *internalStopFlag) {

View File

@ -38,7 +38,7 @@ func (c *Conn) Read(b []byte) (n int, err error) {
func (c *Conn) Write(b []byte) (n int, err error) { func (c *Conn) Write(b []byte) (n int, err error) {
err = c.Conn.Write(c.ctx, websocket.MessageBinary, b) err = c.Conn.Write(c.ctx, websocket.MessageBinary, b)
return len(b), err return 0, err
} }
func (c *Conn) RemoteAddr() net.Addr { func (c *Conn) RemoteAddr() net.Addr {