-
Notifications
You must be signed in to change notification settings - Fork 89
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
mqtt client will never realize the connection is closed when TCP connection established but CONACK not received #109
Comments
why does it matter since that's not a real connection ? |
Since the client dosen't receive any feedback, the client code will not be triggered. |
@SunFeiyue I think that it makes sense. The close handler is supposed to be called when the TCP connection is closed and should not be tied to the CONNACK. Thanks for raising it. |
@ppatierno ok, so that would mean that the client sends at least a CONNECT message right ? |
I thought the client would not send anything first :-) |
@vietj the client should do that: opening the TCP connection, sending the CONNECT and waiting for the CONNACK. I think that the problem they are facing is about the CONNECT cannot reach the server (so it doesn't send CONNACK) or the client doesn't receive a CONNACK and somehow the server closes the TCP connection (or it's interrupted). Is that right @SunFeiyue ? |
if CONNECT does not reach the server then it will not help because the handler won't get MqttEndpoint and won't have opportunity to set a close handler |
Yeah agree but @SunFeiyue is talking about "the underlying TCP connection is disconnected" so it should be detected at Netty "level" on the client and the close handler should be called. Of course, if the TCP connection is not disconnected, the client could wait indefinitely because it can be related to the CONNECT or CONNACK lost but with the TCP connection still in place. |
I think we can have a |
Yes, right. Sorry for later reply. |
I don't think this fix can solve my problem actually. In the situation I mentioned above, io.vertx.mqtt.impl.MqttClientImpl#handleClosed will be called when the TCP connection become disconnected, but the close handler will not be called, just because the 'isConnected' field is false. void handleClosed() {
synchronized (this.connection) {
boolean isConnected = this.isConnected;
this.cleanup();
if (this.closeHandler != null && isConnected) {
this.closeHandler.handle(null);
}
}
} |
@SunFeiyue , the source code for the void handleClosed() {
synchronized (this) {
boolean isConnected = this.isConnected;
this.isConnected = false;
if (!isConnected) {
return;
}
}
Handler<Void> handler = closeHandler();
if (handler != null) {
handler.handle(null);
}
} |
Sorry, it was a miss click(closing this issue). PR is also reverted |
yes, it is. I have seen this lastest source code. In the lastest |
@SunFeiyue, I agree. I think the |
This change forks the MqttClientImpl from vertx-mqtt, since the connection handling is broken again.
For the following situation :
In this situation, the mqtt client "connect handler" will not be called because CONACK is not received, the mqtt client 'close handler' will not be called because 'isConnected' is false. So the client will never realize the connect result because it doesn't receive any feedback, except monitoring the 'isConnected' value.
The text was updated successfully, but these errors were encountered: