-
Notifications
You must be signed in to change notification settings - Fork 534
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
connect:packets.ReadPacket block when network is unstable #354
Comments
if we can call SetReadDeadline on c.conn when call packets.ReadPacket? |
I have the same problem.. https://github.com/eclipse/paho.mqtt.golang/blob/master/packets/packets.go#L105
|
I found a solution
and i add SetNoDelay(true) https://github.com/eclipse/paho.mqtt.golang/blob/master/client.go#L259 func openConnection(uri *url.URL, tlsc *tls.Config, timeout time.Duration, headers http.Header) (net.Conn, error) {
conn, err := openConnection1(uri, tlsc, timeout, headers) // old openConnection
if err != nil { return nil, err }
fmt.Println("linux settigs for socket")
tcpConn := conn.(*net.TCPConn)
err = tcpConn.SetNoDelay(true)
if err != nil {
fmt.Println("error in SetNoDelay for the connection!")
return nil, err
}
return conn, nil
} |
We are experiencing the same issue right now. Due to some weird network settings, sometimes TLS data flow fails to start. Thus, the If we set deadline before calling
Same applies to |
I believe this was fixed by PR #603 which set a deadline for the handshake. Closing this for now (as it's been a while) but if anyone is still experiencing issues please feel free to reopen. |
in our project of IOT with edge and server. when network is unstable, we found the packets.ReadPacket blocked.
from log,we can see output "connect started",then no execution.
i think, ReadPacket calls io.ReadFull will block if the server cannot response.
so if we can add some timeout to check or avoid.
orelse we need to put the client connect procedure in the go func().
The text was updated successfully, but these errors were encountered: