stefandreyer / CODESYS-MQTT

MQTT client library for CODESYS, supporting all QoS
MIT License
113 stars 26 forks source link

Codesys not connecting to mqtt server #27

Closed sanderobdeijn closed 4 years ago

sanderobdeijn commented 5 years ago

I have a Wago PFC100 and I have a mqtt server running in my local network without authentication. I have tried the testMQTT(client:={mqttserver:1883} test function but the plc doesn't seem to connect to the mqtt server. When I look at MQTTClient > MQTT_Control > sResultIp the value is empty. When I look at #3 I think this value should be set. If this doesn't works it suggest a dns issue?

stefandreyer commented 5 years ago

Hi Sander,

does you URL_DATA looks like this? grafik

Do you realy write testMQTT(client:={mqttserver:1883} ?

should look like: testMQTT(client:='mqttserver:1883')

BR Stefan

sanderobdeijn commented 5 years ago

what i wrote was: testMQTT(client:='DESKTOP-2NKGLRM:1883'); And my url data looks like this. CodeSysUrlData And I don't see a connected client to my mqtt server. Connecting by Ip doesn't work also.

stefandreyer commented 5 years ago

Hi Sander,

with a static IP it have to look like: grafik

With static IP I don't use DNS, this have to work.

You may look in ErrorHistory in HANDL_MQTT, maybe you have a problem with dynamic memory.

If this, I don't stat conecting or spliting connection string.

BR Stefan

stefandreyer commented 5 years ago

Hi Sander,

with a static IP it have to look like: grafik

With static IP I don't use DNS, this have to work.

You may look in ErrorHistory in HANDL_MQTT, maybe you have a problem with dynamic memory.

If this, I don't stat conecting or spliting connection string.

BR Stefan

sanderobdeijn commented 4 years ago

Hi Stefan I have set a static ip in the web based management page. This doesn't fix it.

I have looked at the error history. And you called it. error dynamic memory It seems to be a dynamic memory issue. What does this mean. Is this a hardware issue or a configuration issue?

primsam commented 4 years ago

Hi Stefan I have set a static ip in the web based management page. This doesn't fix it.

I have looked at the error history. And you called it. error dynamic memory It seems to be a dynamic memory issue. What does this mean. Is this a hardware issue or a configuration issue?

Hi , That ist a configuration issue . You need to increase the dynamic memory

Right click on the application

sanderobdeijn commented 4 years ago

How much memory do I need? Do you know? And can you have more dynamic memory than ram or are they linked?

For others I have increased my memory to 150 mb or 153600 bytes and now it works. @stefandreyer you should put this in the setup instructions maybe.

stefandreyer commented 4 years ago

Hi Sander,

here you see your usage of dynamic memory in bytes: grafik

If you use more subscriptions and more instances of callback FBs this will grow.

and yes, it could be usefull to set up some setup instructions ;)

BR Stefan

sanderobdeijn commented 4 years ago

this usage is in bytes or mb? 100 mb wasn't enough for the GreatExampleOfAdvantages project. my plc only has 256 mb ram does this also limit the dynamic memory?

primsam commented 4 years ago

This is displayed in Bytes i think. At least when i limit Dynamic memory at 20000 Bytes it run without Problems

stefandreyer commented 4 years ago

Hi,

yes these are Bytes. I testet the GreatExampleOfAdvanteges with 20000Bytes(20kByte).

At most I setup my Raspi with 2000000 Bytes and got enough left.

@sanderobdeijn yes your physical memory limits the dynamic memory. But my lib takes only veeery few of it. I think with 1000000(1MByte) you can make almoste everythink with my lib on your plc... 100MBytes(100000000) are more then enough for this example.

BR Stefan

sanderobdeijn commented 4 years ago

yeah my bad I forgot about Kbytes. I have used 153600 bytes or 150 kBytes. It has been long since I had to calculate in bytes.