I am using Arduino Uno with ethernet shield W5100 to connect with my Tcp Server. Currently I my server is sending message to Arduino in every 60 seconds to check state. After connection with internet it's working fine, but after several minutes server can't send information to Arduino. Below is my code. Where is problem? I have diffrent server connected with Tcp Server and it's working fine.
And I removed all calls to setup(). It's the same result. Arduino is connected with TcpServer, receive several packages and then is frozen. It's not disconnected but not receive new data too.
So it never once gets to "Disconnecting.", "Disconnected." the whole time?
My advice is to add in some additional Serial.println statements to get more information about what's happening.
Piotrek50501:
And I removed all calls to setup().
You can call setup() from loop. It's just a bad idea to call setup from inside setup because you could easily have a situation where that happens over and over again until you run out of memory and crash the processor. You could accomplish the same thing safely with a while loop.
Rather than calling setup from loop, I would probably move the code that needs to be run again after a disconnect to a separate function and then call that function from both setup and loop. That way you don't unnecessarily run the code that only ever needs to be called once. For example, there is absolutely no reason you would need to run Serial.begin(9600) multiple times in your code.
I would like to compare the string of characters which I get from the server. And if I will have state = "String/" and readString = "String/" then I would like to execute code from
if (readString == state)
I don't know how to do it in the case without String. So How can I add next sign to readString variable when this variable isn't as String?
I found the problem. Problem is with my Tcp Server. I am hosting my server on mydevil.net and several minutes ago I was trying connect my arduino with local server. With local server is working correctly.
So I have to change server. Where can I host my server?
Piotrek50501:
I found the problem. Problem is with my Tcp Server. I am hosting my server on mydevil.net and several minutes ago I was trying connect my arduino with local server. With local server is working correctly.
So I have to change server. Where can I host my server?
does the server use https? copy the response bytes to Serial Monitor to see the error.
Now I changed router, I added in Router Settings for "Access Control" in firewall tab "Allow" for all. The result is the same. So is strange that I got always six times:
I was trying through last 2 hours with my code and with the local server. It's working correctly. But with external hosting is a problem.
I think that at this moment it isn't important my code for Arduino. I know that I have to make it better, but now I would like to resolve the problem with the connection between my hosting and Arduino.
Maybe my hosting has a lot of problems? Maybe I have to change hosting company and try to do it there?
Could you recommend me any hosting company to testing my server with connected Arduino?