We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Many cloud services use MQTT and they require an initial connection using a username and password. I have not found the ability to set these parameters with any of the MQTT type libraries i have found for processing. Is this capability available ?
Answers
here is an example from the mqtt library
i added a few client connect strings
the one for broker.shiftr.io has user and password strings
the code publishes a message with every key press
it also times out in 15 seconds
try uncommenting some of the other client.connect command lines (only one at a time)
and try some of the other subscriptions
test.mosquitto.org has a lot of messages in the $SYS subscriptions
hope this helps
you may already know all of this, but someone else may not
some of the code got messed up by the forum software
the beginning of the code should read as follows
Thank you Joel
your example obviously works with your broker but when i try to use this format with the service i want to work with, i get the following:
MQTT 1.6.1 by Joel Gaehwiler https://github.com/256dpi
[MQTT] failed to connect: MqttException
[MQTT] failed to subscribe: Client is not connected
here is the client connect format i am trying to use, where the user name is the 70B3.... section and the pw is the xPD8..... section (replacing your try:try )
are these incompatible with this implementation ? or did i not implement it properly ?
i can use this user/pw with other clients on an Android device or MQTTlens on a pc and it works just fine. I would like to be able to do the same with processing.
let me know if you have any suggestions.
client.connect("mqtt://70B3D57ED00009CB:xPD8muP6/3ZG0q8IMudHS4cAKpynuwTeEQeGOxtQxT4=@staging.thethingsnetwork.org","processing55AA"); // try:try = user:pwd
thanks Ken
it is the forward slash in the password that throws the exception
without it you get "[MQTT] failed to connect: Not authorized to connect"
btw. i am not joel
it is because the string is a URL, therefore the slash has to be escaped with %2F (replaced)
see http://w3schools.com/tags/ref_urlencode.asp
this should work
That solved the issue.
Now i am able to connect and subscribe and publish properly thru this broker using the test account i used as an example. thanks for taking the time to provide a solution and explanation regarding URL encodeing.
Ken