-
Notifications
You must be signed in to change notification settings - Fork 90
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
change isConnected flag only in handleClose #113
Conversation
@vietj , @ppatierno , can you review, please? |
@Sammers21 , the |
I think we need to have a test for the issue you are trying to fix |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Sammers21 with this change, the client is going to close the TCP connection if it gets a negative CONNACK from the server, right? Why it should do that? On the same TCP connection the client could be able to send a new CONNECT packet to be successful (maybe the problem is about authentication with username and password). Tbh I don't remember why the close handler was tight to the isConnected flag so that we can just remove the check on isConnected in the handleClosed.
Yes, but the current API does not allow as to do this, I mean sending COONECT twice on the same connection.
I think we need to clearly define what |
@ppatierno @Sammers21 Or, is it possible to add a new flag to indicate the TCP connection is connected? |
I think having first a test that reproduce the issue would be good, so we can then settle or not on the usefulness of the PR. |
I agree with Julien, we first need a test for reproducing it and then we can think about the better solution. |
public class ConnectHandlerNotCalled extends io.vertx.core.AbstractVerticle {
public static void main(String... args) {
io.vertx.core.Vertx.vertx().deployVerticle(ConnectHandlerNotCalled.class.getName());
}
@Override
public void start() throws Exception {
io.vertx.mqtt.MqttServer.create(vertx).endpointHandler(endpoint -> {
System.out.println("CONNECT from " + endpoint.clientIdentifier());
// Do not send CONNACK
// endpoint.accept(false);
}).listen(1883, lh -> {
System.out.println("Server is listening");
io.vertx.mqtt.MqttClient.create(vertx).connect(1883, "127.0.0.1", ch -> System.out.println("ConnectHandler called"));
});
}
} |
6b1f5bf
to
8c7e60a
Compare
Just added a test case. If we don't receive a CONNACK packet within a period of time, we will treat it as an unsuccessful attempt to establish a MQTT session |
8c7e60a
to
820c610
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also recommend to change the title, if possible.
The isConnected variable is still changed in the conAck-handler
Async async = context.async(1); | ||
MqttServer mqttServer = MqttServer.create(vertx); | ||
mqttServer.endpointHandler(mqttEndpoint -> { | ||
vertx.setTimer(serverResponseInSeconds * 1000, action -> mqttEndpoint.close()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not see a reason to set a timer that closes the endpoint.
It is sufficient to do nothing to make the test pass.
Keeping this action could lead to the conclusion that your waiting for the TCP-Connection to be closed, which is not what is intended
Partly solves #109