Do I have to modify my code?
Of course you do.
void httpRequestToWebServer() {
webClient.stop(); // close any connection before send a new request, this will free the socket on the WiFi shield
ASSuming that webClient is a connected client is NOT a good idea.
What is the point of making a GET request and not reading the server response? Perhaps a clue-by-four would present itself.
void loadClient(){
while (Serial.available()) {
params = Serial.readString(); // "azione=accendi&sensore_id=12"
httpRequestToWebServer();
}
}
Excuse my ignorance, but why the hell is that a while loop?
But now the problem is that if I call a remote server from Arduino client, when it reply (with a webpage) it is interpreted as a new connection to the Arduino server, messing up the request.
That statement doesn't make sense.
You make a GET request, but you neither read the response, which will cause the connection to be properly closed once all the data has been read nor explicitly close the connection (telling the server to f**k off).
Do one of them, and I'll bet your issues get cleared up.