From 45d12b11a88808b98dd91c3321a2bf6715bfeb1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniele=20Vigan=C3=B2?= Date: Sun, 21 Jun 2020 22:49:35 +0200 Subject: [PATCH] Fix 400 error with Arduino telemetry and Nginx This was caused by the client not waiting for a response. Also Content-Length header was bogus. --- arduino/tempLightSensor/tempLightSensor.ino | 2 +- docker/ingress/nginx.conf | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/arduino/tempLightSensor/tempLightSensor.ino b/arduino/tempLightSensor/tempLightSensor.ino index cacc0ba..f6d1f4b 100644 --- a/arduino/tempLightSensor/tempLightSensor.ino +++ b/arduino/tempLightSensor/tempLightSensor.ino @@ -162,7 +162,7 @@ void postData(const netConfig &postAPI, const String &URL, const DynamicJsonDocu ethClient.println(postAPI.port); ethClient.println("Content-Type: application/json"); ethClient.print("Content-Length: "); - ethClient.println(measureJsonPretty(json)); + ethClient.println(measureJson(json)); ethClient.println("Connection: close"); ethClient.println(); serializeJson(json, ethClient); diff --git a/docker/ingress/nginx.conf b/docker/ingress/nginx.conf index ae019e3..651bf1a 100644 --- a/docker/ingress/nginx.conf +++ b/docker/ingress/nginx.conf @@ -51,6 +51,7 @@ http { location / { proxy_pass http://bite; + proxy_http_version 1.1; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-Host $host:$server_port; @@ -59,6 +60,9 @@ http { proxy_read_timeout 300; proxy_connect_timeout 300; + + ## !- This is mandatory for IoT that do not wait for a reply -! ## + proxy_ignore_client_abort on; } location /mqtt {