eclipse-paho / eclipse-paho/paho.mqtt.java
Unable to connect / connection lost due to hardcoded socket timeout and readMqttWireMessage SocketTimeoutException
- Dominant language
- Java
- Stars
- 2.3k
- Forks
- 919
- PR merge metrics
- No merged PRs in 30d
Description
- [x] Bug exists Release Version 1.2.4 ( Master Branch)
The bug exists in 1.2.4 (and most likely in older versions, at least 1.2.3). It could be due to a fix for [issue 719](https://github.com/eclipse/paho.mqtt.java/issues/719).
Sometimes, depending on timing of client and server, the client cannot connect. The reason appears to be that the `TCPNetworkModule` (line 75) sets a hardcoded SoTimeout of 1000, which causes the `MqttInputStream.readMqttWireMessage()` method to return null (due to a SocketTimeoutException).
`CommsReceiver.run()` reads the null message, checks whether `ClientComms` is connected (which it is not at this time, as the client is still `CONNECTING`) and fails. The check for `!clientComms.isConnected()` was added as bugfix to issue 719.
Contributor guide
Assessment
This issue has not been assessed yet.