2
I have a server running on Windows 7 PC and am using Pycharm IDE to edit and simulate. This server is receiving information from an ESP32 module that is connected on the same PC network. Sending the ESP32 module to the server:
Serial.println("========= Inicio post para servidor ==============");
http.begin(client, Send_http_server(dia,temperatura, umidade, pressao, altitude, RPM, str_biruta, est_motor1, flag_motor1, pluviometro)); //HTTP
http.addHeader("Content-Type", "application/json");//inclui um cabeçalho da aplicação http
int httpCode = http.POST(Send_http_server(dia,temperatura, umidade, pressao, altitude, RPM, str_biruta, est_motor1, flag_motor1, pluviometro));
String payload = http.getString(); //Get the response payload
http.end();//finaliza a conexão alivia o sistema
Serial.print("Valor recebido do Rest httpCode:");
Serial.println(httpCode); //imprime o valor recebido do servidor
Serial.println("Play Load:" + payload); //Print request response payload
get_http(httpCode);
Serial.println("========= Fim post para servidor ==============");
On the server I have:
@app.route('/dados_esp32/<string:dados>', methods=['GET', 'POST'])
def parse_request(dados):
if request.method == 'POST':
bla.bla .bla....
In the first tests the sending happened all right, my server received and processed;
from one hour to another the server failed to receive the POST
.
I tried several things without success, I tried the firewall and still does not receive the POST
.
But when I send a request from the server to the ESP32 module they communicate without error. In order for the system to work as intended, the module must trigger uploads to the server and not the other way around.
Including more information:
Try immediately before the
if request.method == 'POST'
placeprint(request.method)
to confirm which method is being received. Another thing is to add all methods in the parametermethods
from Developer. Another thing: how are you lifting the Flask server? Finally, trynetstat -an | find /i "listening"
to see open doors and listening to connections.– Paulo Marques
Hello Paulo Marques, thank you for your attention! I tried the alternatives indicated but without result yet, I tried to create a rule for the port 5000 in the firewall, I could not release the access.
– Paulo Furlan
Do not put greetings and thanks in the question. Also do not include issues unrelated to IT, the system informs us that it is a new user.
– Augusto Vasques
Analyzing the question, there is only one fragment of the error message, it is necessary to see completely to initialize the analysis of which leads the server to refuse the connection. What’s in the log file 2021-03-04.txt? Do not publish code or log as image
– Augusto Vasques