Sorry to disturb the communicty but I need your help w/ a big project requiring, in particular, :
Ethernet TCP communication with a remote server (outside local network) to upload real-time data from OPTA (input, serial1, rs485, and so on...), pipe always open,
I tried to put clientWeb declaration before TCP connect. But always the same pb. Web server doesn't work. I think that clientTCP.connect must take the priority.
I think that there is a conflict w/ EthernetClient. But how to solve it, I don't kown.
All the ideas will be welcoming, believe me
In order to be sure, I follow your advice about MBED version. I mean upgrade my Arduino v1.8.19 w/ the last one, V4.2.4.
And now, it works !
It is a good news but I don't understand why. V4.2.1 is not old. It should be work w/ mDNS library, webServer and tcpClient.
I will continue my project w/ a particular attention about this part. And if pb, I will come back to this topic.
Sorry for the disturbance.
Thanks
To answer you, here is an extract of my project into a dedicated sketch and small adaptation in order to work in stand alone.
For information, all connection security (reboot, missing connection, and so on...) have been removed for easy reading
Hi,
Thanks for your message.
In my example above, for me, the only blocking method is tcpConnect.
Indeed, if my TCP connector is not open or not accessible, the timeout accordingly is ~18sec. before to continue.
It is the reason why in my global project, the tcpConnect is executed in low priority. I mean only when there is no others sensitives sensors.
So, on the webserver part, the data will be sent to the browser only once in the loop on the clientWeb connection because you have nested inside a if (clientWeb) instead of a while (clientWeb) right?
Yes it is.
It is just to send few data on request from my Android device application in the same local network.
Reason why I use mDNS in order to able to find OPTA web server in DHCP mode.
Hi Juraj,
I come back to you about my initial issue.
Because the pb is present yet
Initially, I thought that it was a conflict between tcp client and web server. But not as wrote above. Sorry for my mistake !
After fully investigation, I discover that there is a conflict between webServer and my RTC module.
This RTC module is implemented w/ NTPClient.h and EthernetUDP.h librairies.
As soon as timeClient.begin(); is called, the webServer becomes blocked few sec. after !
Maybe I did a mistake but I don't know where. Here is the part of code blocking the webServer.
No. I work w/ a small main.ino and a lot of different module (.h && .ino).
Each modules are called into main loop the fastest as possible (no delay() implemented)
I know perfectly where are the blocking method.
Therefore, as soon as I trigger a sensitive function, I stop calling modules accordingly. For example, tcp module or rtc module or ...
For the rest, all works together w/o issue
Here is my solution in order to solve this issue between webServer and NTPClient, and allow both working simultaneously.
Put begin()/update() and add end() into a function periodically called instead of begin into setup(), update() into loop() and never end(). I mean :
@manucast
sorry for the question again but I don't understand how you can make the webserver work when a client is connected without blocking the loop by not executing tasks. Thanks for the answer
To be clear, the clients trigger a small request when it needs to retrieve informations from OPTA.
To avoid blocking on clientWeb.readStringUntil('\r') command, I use a timeout (.setTimeout()).
I noticed that if client connected to local network by :
by RJ45, setTimeout(10) is enough,
by WiFi, timeout value must increase to 800ms. I mean setTimeout(800). Otherwise, the request is not 100% sure to be complet.