I was able to successfully develop a B4J desktop application to connect to a data streaming API using MQTT after overcoming some initial difficulties covered in this thread:
Websocket connection to MQTT based API.
I am now trying to connect to the same API using an ESP8266 based device and so I'm in the process of porting my B4J code to B4R, however, I am uncertain whether the capabilities of the rMQTT library will allow that.
As explained in the original thread, the authentication call returns an "authorised url" and I can extract that along with the clientId from the response obtained from the authentication call using this
JSON Parsing Code Snippet. The format of the "authorised url" (with line feeds added to make the query parameters more visible) is:
wss://xxxxxxxxxxxxxxxxxx.amazonaws.com/mqtt?
X-Amz-Algorithm=AWS4-HMAC-SHA256&
X-Amz-Credential=xxxxxxxxxxxxxxxxxxxxxx&
X-Amz-Date=20210429T234727Z&
X-Amz-Expires=86400&
X-Amz-SignedHeaders=host&
X-Amz-Signature=xxxxxxxxxxxxxxxxxxxxxxxxx&
X-Amz-Security-Token=xxxxxxxxxxxxxxxxxxxxxxxxxxx%3D%3D
So my question is can I just use that "authorised url" as the HostName parameter in the mqtt.Initialize2 statement?
It seems from the comment "Note that the host name should not include the scheme (tcp://)" by
@Erel in this
post that at least I'd need to remove the wss:// prefix, but will mqtt.Initialize2 handle the query parameters included in the "authorised url"? Or do I need to use just xxxxxxxxxxxxxxxxxx.amazonaws.com/mqtt in the mqtt.Initialize2 statement and then include the query parameters in a mqtt.Connect2 statement? If so, how do I incorporate these multiple connection options? However perhaps I'm "barking up the wrong tree" because I think there are only a defined set of allowable connection options.
Any suggestions or guidance would be greatly appreciated.