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

Subscriber message,CONNECT failed as CONNACK contained an Error Code: BAD_USER_NAME_OR_PASSWORD #641

Open
zqb666 opened this issue Sep 3, 2024 · 2 comments
Labels

Comments

@zqb666
Copy link

zqb666 commented Sep 3, 2024

image

1.3.0
hello. how to set username and password when i connect ?
with mqtt5 client

@zqb666 zqb666 added the question label Sep 3, 2024
@pglombardo
Copy link
Contributor

Hi @zqb666 - It depends on how the broker authorization is setup but for simple auth:

final Mqtt5BlockingClient client = Mqtt5Client.builder()
                        .identifier(getClientId())
                        .serverHost(HOST)
                        .serverPort(PORT)
                        .simpleAuth()
                            .username(USERNAME)
                            .password(ByteBuffer.wrap(PASSWORD.getBytes(StandardCharsets.UTF_8)))
                        .applySimpleAuth()

See also this blog post: Authentication with Username and Password

@pglombardo
Copy link
Contributor

Hi @zqb666 - did this help out at all? Did you find a solution that works for you?

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

2 participants