Skip to content
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_connect does not generate a client.error if wrong username and/or password is provided #184

Open
PitHerm opened this issue Oct 25, 2023 · 1 comment

Comments

@PitHerm
Copy link

PitHerm commented Oct 25, 2023

i tried your simple publisher example
and modified the parameter of mqtt_connect
from:

/* Send connection request to the broker. */
mqtt_connect(&client, client_id, NULL, NULL, 0, NULL, NULL, connect_flags, 400);

/* check that we don't have any errors */
if (client.error != MQTT_OK) {
    fprintf(stderr, "error: %s\n", mqtt_error_str(client.error));
    exit_example(EXIT_FAILURE, sockfd, NULL);
}

with the correct username and password to:
/* Send connection request to the broker. */
mqtt_connect(&client, client_id, NULL, NULL, 0, "paul", "paula", connect_flags, 400);

/* check that we don't have any errors */
if (client.error != MQTT_OK) {
    fprintf(stderr, "error: %s\n", mqtt_error_str(client.error));
    exit_example(EXIT_FAILURE, sockfd, NULL);
}

i received no errors and a connection which worked.
then i tried wrong username and wrong password

/* Send connection request to the broker. */
mqtt_connect(&client, client_id, NULL, NULL, 0, "otto", "otto", connect_flags, 400);

/* check that we don't have any errors */
if (client.error != MQTT_OK) {
    fprintf(stderr, "error: %s\n", mqtt_error_str(client.error));
    exit_example(EXIT_FAILURE, sockfd, NULL);
}

i received no errors and no connection to the broker was established
after pressing the ENTER key to send the time i received an error

./simple_publisher is ready to begin publishing the time.
Press ENTER to publish the current time.
Press CTRL-D (or any other key) to exit.

./simple_publisher published : "The time is 2023-10-25 06:55:24"
datetimeThe time is 2023-10-25 06:55:24
error: MQTT_ERROR_SOCKET_ERROR

if no connection was established to the broker there should be an error message.

@conggalam12
Copy link

@PitHerm I have the same error , do you fix it ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants