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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reconnect not working depending on where credentials are provided #574

Open
inad9300 opened this issue May 25, 2023 · 0 comments
Open

Reconnect not working depending on where credentials are provided #574

inad9300 opened this issue May 25, 2023 · 0 comments
Labels

Comments

@inad9300
Copy link

inad9300 commented May 25, 2023

馃悰 Bug Report

If credentials are provided to Mqtt5ClientBuilder, reconnections to a broker when the broker is restarted work. However, when provided to Mqtt5ConnectBuilder (as exemplified in the docs), initial connections work but reconnections don't! The following error message is displayed:

CONNECT failed as CONNACK contained an Error Code: BAD_USER_NAME_OR_PASSWORD.

What is the difference between providing them in one place versus the other? I was shocked to find that there were two possible places, to be honest, and it took me a long time to come to this lucky realization, given the lack of documentation.

During the course of my investigation, I sometimes saw a different warning related to SSL (which I'm not using), saying "Username: null; SSL certificate subject DN: unavailable". They appeared with the same frequency as I have configured reconnects to occur, so they must have been logged on reconnection attempts. I'm not sure if these warnings stem from the same problem or not, but they don't show up anymore.

馃敩 How To Reproduce

Steps to reproduce the behavior:

  1. Start an MQTT client and server
  2. Restart the server (I'm using docker, so I use docker compose restart mqtt_server)
  3. Verify that the client is automatically reconnected to the server in one case but not the other

Code sample

var client = Mqtt5Client
    .builder()
    .serverHost("host")
    .serverPort(port)
    // When using these, both connecting and reconnecting work:
    .simpleAuth()
    .username("user")
    .password("password".getBytes())
    .applySimpleAuth()
    .automaticReconnect()
    .initialDelay(1, SECONDS)
    .maxDelay(1, SECONDS)
    .applyAutomaticReconnect()
    .identifier(randomUUID().toString())
    .buildAsync();

var connAck = client
    .connectWith()
    .sessionExpiryInterval(60)
    // When using these, connection works but reconnection does not:
    // .simpleAuth()
    // .username("user")
    // .password("password".getBytes())
    // .applySimpleAuth()
    .send()
    .get(30, SECONDS);

Environment

Where are you running/using this client? Docker
What version of this client are you using? 1.3.1
JVM version? 17
Operating System? Ubuntu
Which MQTT protocol version is being used? 5
Which MQTT broker (name and version)? Apache ActiveMQ Artemis 2.28.0

@inad9300 inad9300 added the bug label May 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant