Are the PLC and the broker on the same network ?
Can you ping broker from the PLC ?
What is the logs in the PLC ? (check /var/log/messages and look for DataAgent messages)
What is the broker ?
I’m connected to a VPN, and I can ping the PLC from my laptop. I can ping the rooter also. So in the MQTT anycloud connection configuration I entered the rooter ip in the hostname because the rooter have access to PLC and to my laptop which have different networks. So no, they don’t have the same networks but the rooter is like a gateway I think.
How can I ping the broker from the PLC ?
My broker is Mosquitto which turned on my server (my laptop ip).
Here are the logs :
Nov 8 04:06:06 PFC300-69594F DataAgent[990]: [Info][Starting with logging level 127][DataAgent.cpp L:476]
Nov 8 04:06:06 PFC300-69594F DataAgent[990]: [Info][Application version: 1.16][DataAgent.cpp L:477]
Nov 8 04:06:06 PFC300-69594F DataAgent[990]: [Info][Command line arguments: -d][DataAgent.cpp L:379]
Nov 8 04:06:06 PFC300-69594F DataAgent[990]: [Info][Detected plcRuntime = CodesysV3][Common/FileSystem.cpp L:54]
Nov 8 04:06:06 PFC300-69594F DataAgent[990]: [Warning][Failed reading CmpApp.Application.1 from /home/codesys/CODESYSControl.cfg][WagoProtocol/FwUpdateConfigTool.cpp L:286]
Nov 8 04:06:06 PFC300-69594F DataAgent[990]: [Info][Configure LoggingLevel = Default][Configuration/ConfigurationManager.cpp L:848]
Nov 8 04:06:06 PFC300-69594F DataAgent[990]: [Info][Configure Connection1.Enabled = true][Configuration/ConfigurationManager.cpp L:811]
Nov 8 04:06:06 PFC300-69594F DataAgent[990]: [Info][Configure Connection1.CloudType = AnyMQTT][Configuration/ConfigurationManager.cpp L:811]
Nov 8 04:06:06 PFC300-69594F DataAgent[990]: [Info][Configure Connection1.Compression = None][Configuration/ConfigurationManager.cpp L:811]
Nov 8 04:06:06 PFC300-69594F DataAgent[990]: [Info][Configure Connection1.AuthenticationMethod = DeviceKey][Configuration/ConfigurationManager.cpp L:811]
Nov 8 04:06:06 PFC300-69594F DataAgent[990]: [Info][Configure Connection1.MessagingProtocol = NativeMQTT][Configuration/ConfigurationManager.cpp L:811]
Nov 8 04:06:06 PFC300-69594F DataAgent[990]: [Info][Configure Connection1.CacheMode = RAM][Configuration/ConfigurationManager.cpp L:811]
Nov 8 04:06:06 PFC300-69594F DataAgent[990]: [Info][Configure Connection1.ProxyType = None][Configuration/ConfigurationManager.cpp L:811]
Nov 8 04:06:06 PFC300-69594F DataAgent[990]: [Info][Configure Connection1.HttpProxyPort = 8080][Configuration/ConfigurationManager.cpp L:811]
Nov 8 04:06:06 PFC300-69594F DataAgent[990]: [Info][Configure Connection1.SendDeviceInfo = true][Configuration/ConfigurationManager.cpp L:811]
Nov 8 04:06:06 PFC300-69594F DataAgent[990]: [Info][Configure Connection1.SendDeviceStatus = true][Configuration/ConfigurationManager.cpp L:811]
Nov 8 04:06:06 PFC300-69594F DataAgent[990]: [Info][Configure Connection1.StandardCommandsEnabled = true][Configuration/ConfigurationManager.cpp L:811]
Nov 8 04:06:06 PFC300-69594F DataAgent[990]: [Info][Configure Connection1.TelemetryStopped = false][Configuration/ConfigurationManager.cpp L:811]
Nov 8 04:06:06 PFC300-69594F DataAgent[990]: [Info][Configure Connection1.Port = 1883][Configuration/ConfigurationManager.cpp L:811]
Nov 8 04:06:06 PFC300-69594F DataAgent[990]: [Info][Configure Connection1.CleanSession = true][Configuration/ConfigurationManager.cpp L:811]
Nov 8 04:06:06 PFC300-69594F DataAgent[990]: [Info][Configure Connection1.UseTLS = false][Configuration/ConfigurationManager.cpp L:811]
Nov 8 04:06:06 PFC300-69594F DataAgent[990]: [Info][Configure Connection1.LastWillEnabled = false][Configuration/ConfigurationManager.cpp L:811]
Nov 8 04:06:06 PFC300-69594F DataAgent[990]: [Info][Configure Connection1.CaFile = /etc/ssl/certs/ca-certificates.crt][Configuration/ConfigurationManager.cpp L:811]
Nov 8 04:06:06 PFC300-69594F DataAgent[990]: [Info][Configure Connection1.LastWillQoS = 0][Configuration/ConfigurationManager.cpp L:811]
Nov 8 04:06:06 PFC300-69594F DataAgent[990]: [Info][Configure Connection1.LastWillRetain = false][Configuration/ConfigurationManager.cpp L:811]
Nov 8 04:06:06 PFC300-69594F DataAgent[990]: [Info][Configure Connection1.Host = ***][Configuration/ConfigurationManager.cpp L:811]
Nov 8 04:06:06 PFC300-69594F DataAgent[990]: [Info][Configure Connection1.ClientId = ***][Configuration/ConfigurationManager.cpp L:811]
Nov 8 04:06:06 PFC300-69594F DataAgent[990]: [Info][Configure Connection1.KeepAliveInterval = 120][Configuration/ConfigurationManager.cpp L:811]
Nov 8 04:06:06 PFC300-69594F DataAgent[990]: [Info][Configure Connection2.Enabled = false][Configuration/ConfigurationManager.cpp L:811]
Nov 8 04:06:06 PFC300-69594F DataAgent[990]: [Info][Initialized][AgentControl/OperationStatusObserver.cpp L:43]
Nov 8 04:06:06 PFC300-69594F DataAgent[570]: Last message '[Info][Initialized][' repeated 1 times, suppressed by syslog-ng on PFC300-69594F.lan
Nov 8 04:06:06 PFC300-69594F DataAgent[990]: [Info][UDP 127.0.0.1:14118 setsockopt SO_RCVBUF: requested 2097152, got 425984][Util/IPC/IpcUdp.cpp L:94]
Nov 8 04:06:06 PFC300-69594F DataAgent[990]: [Info][Connection1: Initialized][AgentControl/AgentBusReaderUdp.cpp L:35]
Nov 8 04:06:06 PFC300-69594F DataAgent[990]: [Info][UDP 127.0.0.1:14119 setsockopt SO_SNDBUF: requested 2097152, got 425984][Util/IPC/IpcUdp.cpp L:170]
Nov 8 04:06:06 PFC300-69594F DataAgent[990]: [Info][UDP 127.0.0.1:14120 setsockopt SO_SNDBUF: requested 2097152, got 425984][Util/IPC/IpcUdp.cpp L:170]
Nov 8 04:06:06 PFC300-69594F DataAgent[990]: [Info][Connection1: Mosquitto Library version:1.6.7][Connection/TransmitterMosquitto.cpp L:183]
Nov 8 04:06:06 PFC300-69594F DataAgent[990]: [Info][Connection1: Initialized][NativeMQTT/TransmitterNativeMqtt.cpp L:23]
Nov 8 04:06:06 PFC300-69594F DataAgent[990]: [Info][Connection1: Initialized][NativeMQTT/DatagramsManagerNativeMqtt.cpp L:27]
Nov 8 04:06:06 PFC300-69594F DataAgent[990]: [Info][Connection1: Initialized][NativeMQTT/CustomDataManager.cpp L:46]
Nov 8 04:06:06 PFC300-69594F DataAgent[990]: [Info][Running][AgentControl/AgentBusReaderBase.cpp L:21]
Nov 8 04:06:06 PFC300-69594F DataAgent[990]: [Err][Connection1: mosquitto_connect_async failed. Error 14: Network is unreachable][Connection/TransmitterMosquitto.cpp L:496]
Nov 8 04:06:06 PFC300-69594F DataAgent[990]: [Err][Connection1: mosquitto_connect_async failed. A System call returned an error: Network is unreachable][Connection/TransmitterMosquitto.cpp L:503]
Nov 8 04:06:06 PFC300-69594F DataAgent[990]: [Warning][Connection1: No connection to broker could be established.][Connection/TransmitterMosquitto.cpp L:506]
Nov 8 04:06:06 PFC300-69594F DataAgent[990]: [Info][Connection1: Running][Connection/TransmitterMosquitto.cpp L:161]
Nov 8 04:06:06 PFC300-69594F DataAgent[990]: [Info][Connection1: Running][NativeMQTT/CustomDataManager.cpp L:53]
Nov 8 04:06:06 PFC300-69594F DataAgent[990]: [Info][Connection1: Running][NativeMQTT/DatagramsManagerNativeMqtt.cpp L:34]
Indeed, I can’t ping my ip (localhost) from the PLC. But this is because I’m connected to a VPN. I think that I should put my broker to a VPS. Because if I turn off my pc, the broker will not receive datas anymore
If I download MQTT Broker into the Wago with SSH access, can it be a solution to my problem ? Thus, I can publish data from codesys directly with “localhost” for hostname into the MQTT Client.
Is the VPN client installed on the PFC? (does the PFC know about the route to 192.168.b.x?)
If not, is it a site-to-site VPN between the “PFC”-router and your office? If so, you need to use 192.168.b.x in the MQTT AnyClient configuration and handle the NAT/ routing on the “PFC”-router.
Configuring the MQTT AnyClient with the router IP won’t work unless you have NAT’ing on it or the MQTT broker is actually running on the router.
NB : My Goal is to publish data in real time on the broker with codesys. And retrieve them with node js (a backend server) NB2: The ping works only in one way from the pc to the devices
Hello,
So your Broker is your PC.
Your PC is remotely connected to the PLC via a VPN.
The PC can ping the PLC and the PLC can ping the PC.
Is the PLC and PC on the same time ? can you check with the WBM that the PLC time and the PC time are synchro ?
Have you done the NTP settings in the PLC to make sure the time is always updated ?
In the PLC when you connect via putty, you can test the connection using:
killall dataagent
to “kill” all cloud connections.
Then to restart is in your current session:
dataagent
If you shutdown the ssh link the dataagent will also be killed.
But by doing this you can retry to connect when doing test without having to reboot the PFC.
(Bonus the log are colored).
Of course, the computer is the last place where you want to put the broker.
And your computer firewall doesn’t accept inbound connection, or at least doesn’t answer to ICMP request (ping).
Depending on which services will publish/subscribe to the MQTT data produced by the PLC, you could afford to install the broker within the PLC, using Docker.
Thank you ! I will do that but last question, if the VPS cannot access to the PLC (there are in different networks) how can I catch the values sent to the broker ?
Thank you I’m trying it now, but do you know why when I want to setup the time of my PLC with NTP Client it show me : ntp.client.updatetime: config_sntp: 8 No functioning time server found
My PLC is configured with different date & time than my PC
DNS & Gateway on the network configuration are set to the router ip (192.168.x.1).
The Wago controller is connected to the switch by rj45 so it should have internet access. I’m lost