Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » 4DIAC - Framework for Distributed Industrial Automation and Control » MQTT - NO Socket issue(Publish and Subscribe FBs do not communicate with QTT)
MQTT - NO Socket issue [message #1834163] Wed, 04 November 2020 07:11 Go to next message
Pradeep Patel is currently offline Pradeep PatelFriend
Messages: 16
Registered: October 2020
Junior Member
I am new to MQTT and trying to use MQTT communication over Ethernet (TCP) interface.
I have downloaded MQTT Paho code from the link provided in 4Diac documentation website. I build it using CMake tool (MinGW compiler) for windows. I got some compilation errors for files in test folder - test1.c, test2.c, test3.c....etc. The error was "sys/socket.h" not found. As i was building for windows i added "#define _WINDOWS 1" at the top of these files to avoid this error. Then i could successfully build MQTT library file libpaho-mqtt3a.dll and libpaho-mqtt3c.dll. Thereafter i rebuild forte including path of these .dll files.
Now I am using blink program as attached to test. Execution of blinking and counting part are both on localhost connected to each other using Publish and Subscribe FBs as shown in the attachment. But when i put ID of Publish as "raw[].mqtt[tcp://192.168.225.180:1883, forte, output]" and ID of Subscribe as "raw[].mqtt[tcp://192.168.225.180:1883, forte, input]", the STATUS output of Publish FB shows "NO SOCKET" and STATUS output of Subscribe FB shows "TERMINATED".
I am using Mosquitto as MQTT broker running at background on windows OS.
I also tried to replace IP address in IDs with "localhost" but problem remains.
I doubt if my .dll files are good. Is there any location where i can get already built .dll files. Please guide in debugging the issue.
index.php/fa/39193/0/
index.php/fa/39194/0/

[Updated on: Wed, 04 November 2020 07:12]

Report message to a moderator

Re: MQTT - NO Socket issue [message #1834165 is a reply to message #1834163] Wed, 04 November 2020 09:05 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 1582
Registered: January 2014
Senior Member

I'm not as fit in MQTT as I would like to be. But one thing that I noticed is that you connected your SD_1 and RD_1 to WSTRING pins. However the raw layer expects pins of type STRING.

NO_SOCKET means that you tried to send something but the FB could not be initialized. So most probably the init failed. For such test I typically do not connect INITO so that I can manually trigger the different events and see the results.
Re: MQTT - NO Socket issue [message #1834176 is a reply to message #1834165] Wed, 04 November 2020 10:53 Go to previous messageGo to next message
Pradeep Patel is currently offline Pradeep PatelFriend
Messages: 16
Registered: October 2020
Junior Member
Thankyou very much Alois. I did the changes suggested by you and now i can see some activities on my broker screen. However, i am still unable see data transferring from Publish to Subscribe. I can see 'OK' on STATUS' output of both Publish and Subscribe FBs. I can see SD_1 input of Publish continuously toggling (true-false) as per blink program logic but i do not see same toggling data on RD_1 output of Subscribe. Also RSP input of Subscribe is 0. Even if i manually trigger this event to 1 there is no effect. Attached is changed 4Diac program and activity messages on Broker screen. Please guide further.
index.php/fa/39195/0/
index.php/fa/39196/0/
Re: MQTT - NO Socket issue [message #1834194 is a reply to message #1834176] Wed, 04 November 2020 16:07 Go to previous messageGo to next message
Pradeep Patel is currently offline Pradeep PatelFriend
Messages: 16
Registered: October 2020
Junior Member
Just a thought - Is this error because i am executing publish, subscribe and broker on one PC? Shall i try executing publish side and subscriber side applications on different PCs ? If i am using two different PCs then where should i execute broker? should it be on both PCs or only one?
Re: MQTT - NO Socket issue [message #1834195 is a reply to message #1834194] Wed, 04 November 2020 17:25 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 1582
Registered: January 2014
Senior Member

I think it would definitely good if you familiarize yourself with MQTT. MQTT is a broker based system where your publish and subdscribes go to a dedicated broker. 4diac FORTE has currently the limitation that within one 4diac FORTE instance you can connect only to one broker. So in your use case you would have somewhere a broker and you specify the broker's address in all of your publish and subscribes.

Regarding your problem: I don't see your full subscribe and publish ID values, but from the description you gave in your first post I think you have to learn about the concept of MQTT topics. An MQTT topic is an identifer you can publish or subscribe to. If you have a publisher and a subscriber which you would like that they are communicating with each other about the same topic you have to specifiy the same topic in both. If I see your code above correctly you have a differetn topic for your subscribe. As noboday is publishing to this topic you are also not receiving anything.

I hope this helps.
Re: MQTT - NO Socket issue [message #1834197 is a reply to message #1834195] Wed, 04 November 2020 17:51 Go to previous messageGo to next message
Pradeep Patel is currently offline Pradeep PatelFriend
Messages: 16
Registered: October 2020
Junior Member
Thank you Alois. After digging out lot on MQTT concept i realized that name of clients have to be different and topics should be same. So i made corrections to name of clients and topics and now it works fine for me. Thanks again.
Re: MQTT - NO Socket issue [message #1834206 is a reply to message #1834197] Wed, 04 November 2020 21:21 Go to previous message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 1582
Registered: January 2014
Senior Member

You are welcome Pradeep. Just one thing. AFAIK the clientid should be the same per device.
Previous Topic:Cannot find FORTE_TestStruct.cpp for struct data types
Next Topic:Deployment Selection area in 4diac IDE 1.13
Goto Forum:
  


Current Time: Thu Apr 18 07:17:54 GMT 2024

Powered by FUDForum. Page generated in 0.02021 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top