cannot get mqtt client blocks to publish to mosquitto broker
I sent a post to the library developer but have not received any feedback. I followed all instructions. Below is what I sent.
I have a question regarding your product: MQTT_Client.
I took the hivemq sample application and removed all but connect and publish blocks.
I am using a local mosquitto broker port 1883, no cert.
Connect succeeds and xConnnected is set true.
xError is true.
wErrorCode and wAddDiagCode are both 16. As a result, publish never attempts. I confirmed in wireshark.
I have wire sharked and it seems connect is ok. I see the connection in MQTT Explorer.
Wire shark shows
connect command
connect response
ping request
ping response
Never any publish messages.
Ping shows an error.
On the publish block
I see the xEnable and xPublish set high/low with the clock but xPublished and xError are always false. I am assuming this is due to the error in mqttdata.
Any suggestions for what is the issue or how to debug/troublehoot?
I am new to PlcNext and we selected this platform specifically for its MQTT support for Azure EventGrid.
I wanted to do some basic learning against mosquitto before I tackle certificates and SSL.
Comments
Hi johnwilliamhoffman,
Just to clarify, you still have the client block in the program, correct?
Is the data in a string format? Notice the example program converts the publish count to a string then feeds it back into the publish block. That strPayload input is specifically looking for a string. More specifically, a json string.
I think some screenshots of the live data would help me troubleshoot remotely.
It might also be worth checking your strURL. I needed to spend some time here as my mosquitto container was not listening to local host it was listening on its own internal ethernet bridge that was created because of the container. You need to point to the containers IP address, not the network bridge.
Hopefully that helps. Don't hesitate to reach out to our US Technical Service team for more assistance!
" You need to point to the containers IP address, not the network bridge." Please explain what this means.
"Don't hesitate to reach out to our US Technical Service team for more assistance!" - How do i do this? I send an email to 'us-info@phoenixcontact.com'. Is there another email address to use?
Here is where I am at today. I went back to the HiveMQ example and modified to use local mosquitto broker.
The xError latches in on the client block, but the block is still connected to the broker. I see the connection count go up/down in MQTT Explorer and I see the connect/ack messages in WireShark.
No publish or subcribe messages in wireshark. I think this is due to the xError, but not sure.
Suggestions?
I now have the local Mosquitto broker working. I am not sure exactly what changed. I started with a new copy of everything and simplified.
Now I am on to the Azure connection which is our actual production use case. It does not work. The connect client block runs and I get failure, 16. Logs show 255.
This is difficult to troubleshoot. Is there a way to get better diagnostics from the blocks to pinpoint the issue?
Can anyone supply an actual example with connection values that work for azure?
We are using the Azure Event Grid, not the Azure IOT Hub. Do you have an example that use the Azure Event Grid? Do you know if this is supported?
This issue is resolved. The Azure block only works with the IOT hub, not the event Grid.