It seams there is a problem with the mbed opta library where changing the connection timeout parameter takes no effect. The connection timeout is thus fixed at 30 seconds and every time there is a disconnection, every intent to reconnect to unavailable server blocks the process for this amount of time. Solving this seams to be a really easy task, so I've tried to look for the mbed opta library sources in order to fix it, but that seams like impossible. Any ideas on how to solve this? Thanks.
You could try pinging the server to check it's responding before trying to connect. I've done that in a few projects to avoid the long timeout when the server isn't available.
Thanks Dave_Lowther, I've tried that myself too but failed to get an ICMP library working on the Opta. Do you have a reference to the library you used. Thanks again a lot.
I was using this library for ESP32. I'm not familiar with the processor in the Opta.
TCP protocol is an engineering marvel, but it has to deal with unexpected network issues and connection breaking, so timeouts are unavodaible. Thug Life.
If you're programming with PLC IDE, it features rich posibilities as multitasking. In my opinion, TCP connection handling must be isolated from I/O processing.
TCP connection, handling and socket R/W can be configured and procesed at your convenience within an Arduino sketch, while I/O periodic processing task can be perfectly coded with ST language in background at 500ms runs. Values can be shared between processes as Global Variables.
'Divide et Impera' also works for coding.
Thanks for the heads up! Interesting what you said. I will give it a try.