-
Notifications
You must be signed in to change notification settings - Fork 29
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
NoConnectionException with Authentication example #3
Comments
Are you listening for the incoming auth message on the authenticated message stream?
You need to send your reply here or the broker will not send a connect ack, hence the client will keep trying to connect. |
yes. But in my case this code will never be reached as you can see in the full output log below. My authenticate message stream:
(this AuthenticationData is just an example, But the Broker would respond to this)
|
Ah yes I see, the client mustn't re-send the connect message while you are awaiting authentication, I've updated the code to try and fix this, could you update your pubscpec.yaml to pull the package from the development branch of the repo and re-test -
Although I have an MQTT5 broker to test against I've not yet set it up to support authentication so I've not tested this outside of unit testing. |
ok. I updated my code and now, I'am in a endless loop of awaiting end of authentication sequence.
My Client does not send an continue authentication package to the Broker. I only see the connect package from the Client to the Broker and the authentication continue package from the Broker to the Client. Maybe I can provide a MQTT5 Broker which supports authentication. I will have a look. Edit2: For this Broker you need a EdDSA KeyPair and to use the 'SMOKER' authentication method. |
From the log you are receiving an authentication message -
You should be picking this up in your listening callback and responding to it as appropriate, eventually sending back an authentication message with a reason code of 'success', this should trigger the broker to send the CONNACK. The client won't do this for you, it can't know when your authentication sequence is complete, so it will just loop waiting for a CONNACK which is what you are seeing. If you can't see the authentication message in your listener callback then we have another problem. |
yes. I added a continue authentication package to the listener where I will send a proof to the Broker (here the proof is just an example). The Broker then would answer with a CONNACK if the proof will be accepted. My listener:
But this package will never be sent to the Broker, when I run the code. You also will never see the print |
OK, what you are doing is correct, you are not receiving the authenticate message on the stream, I think I know why, I've updated the code, could you pub get and retry please. |
I updated the code and tried again but the same result. |
OK, when are you actually listening in your code? You should do this after you call client.connect, you probably are, just checking this. |
after the client.connect. I used your example and changed only the broker, auth_method, auth_data and the listener as you can see above. |
Yes OK, I can't see why this doesn't at least put the authenticate message on the listening stream. I'll have to set up a broker I can authenticate against to get any further. Thanks for your feedback I'll update this issue as soon as I can. |
Ok. Thank you. |
OK, I may have got this now, please pull the latest code and update your code to listen for auth messages before you call connect, I've updated the example to show this. If it doesn't work could you please supply a log. |
Now it works as expected. Thanks. Here to log (without the re-authentication):
If you would like to test this authentication method ('SMOKER') by yourself, let me know and I can share my example. |
Thanks for the testing. I've re published the package at version 1.1.0. Please raise any other issues you may encounter. |
I'm not sure what I doing wrong but when I'm using the example for authentication with my specific Broker, I always get the following exception:
mqtt-client::NoConnectionException:` The maximum allowed connection attempts ({3}) were exceeded. The broker is not responding to the connection request message
As you can see in the log, my Broker replies to the connection message but the Client does nothing with the authentication message. Instead, he tries to connect again, until he reached the maximum attempts.
So the part (
client.authentication.listen((final authMessage) { ... }
) where I should do the stuff and send back an authentication message, will never reached.Did I forget something?
The text was updated successfully, but these errors were encountered: