{"action":"created","issue":{"url":"https://api.github.com/repos/letscontrolit/ESPEasy/issues/1066","repository_url":"https://api.github.com/repos/letscontrolit/ESPEasy","labels_url":"https://api.github.com/repos/letscontrolit/ESPEasy/issues/1066/labels{/name}","comments_url":"https://api.github.com/repos/letscontrolit/ESPEasy/issues/1066/comments","events_url":"https://api.github.com/repos/letscontrolit/ESPEasy/issues/1066/events","html_url":"https://github.com/letscontrolit/ESPEasy/issues/1066","id":304300134,"number":1066,"title":"empty http responses (ESPEasy 2.0 on SONOFF basic)","user":{"login":"pljakobs","id":13985375,"avatar_url":"https://avatars1.githubusercontent.com/u/13985375?v=4","gravatar_id":"","url":"https://api.github.com/users/pljakobs","html_url":"https://github.com/pljakobs","followers_url":"https://api.github.com/users/pljakobs/followers","following_url":"https://api.github.com/users/pljakobs/following{/other_user}","gists_url":"https://api.github.com/users/pljakobs/gists{/gist_id}","starred_url":"https://api.github.com/users/pljakobs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pljakobs/subscriptions","organizations_url":"https://api.github.com/users/pljakobs/orgs","repos_url":"https://api.github.com/users/pljakobs/repos","events_url":"https://api.github.com/users/pljakobs/events{/privacy}","received_events_url":"https://api.github.com/users/pljakobs/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2018-03-12T09:43:50Z","updated_at":"2018-03-12T12:14:07Z","closed_at":null,"author_association":"NONE","body":"### Steps to reproduce\r\nBuild the current 2.0 branch for 1024kB/DOUT and flash to a SONOFF basic (integrated ESP8266 relay)\r\non any linux system go\r\n'''wget -O - http://<sonoff-ip>/control?cmd=status,gpio,12'''\r\nwatch an empty reply probably 7 out of 8 times\r\nproblem is reproducible after reboots, soft and hard on two different SONOFF boards\r\n\r\n### Expected behavior\r\nShould respond with a json structure describing the state of gpio 12\r\n\r\n### Actual behavior\r\nEmpty response:\r\n```\r\nHypertext Transfer Protocol\r\n    HTTP/1.1 200 OK\\r\\n\r\n    Content-Type: application/json\\r\\n\r\n    Content-Length: 0\\r\\n\r\n    Connection: close\\r\\n\r\n    Access-Control-Allow-Origin: *\\r\\n\r\n    \\r\\n\r\n    [HTTP response 1/1]\r\n    [Time since request: 0.009015000 seconds]\r\n    [Request in frame: 126]\r\n```\r\nafter that, the browser sends a fin ack and ESPEasy responds with a rst ack\r\nfrom the ESPEasy log:\r\n```\r\nEVENT: Clock#Time=Mon,09:40\r\nEVENT: Clock#Time=Mon,09:40 Processing time:90 milliSeconds\r\nsendcontent free: 18184 chunk size:340\r\nWD   : Uptime 34 ConnectFailures 0 FreeMem 18576\r\nsendcontent free: 18184 chunk size:340\r\nsendcontent free: 17736 chunk size:388\r\nsendcontent free: 17736 chunk size:382\r\nsendcontent free: 17736 chunk size:387\r\nsendcontent free: 17736 chunk size:393\r\nsendcontent free: 17736 chunk size:389\r\nsendcontent free: 17488 chunk size:391\r\nsendcontent free: 17536 chunk size:391\r\nsendcontent free: 17520 chunk size:373\r\nsendcontent free: 18088 chunk size:427\r\nsendcontent free: 18064 chunk size:424\r\nsendcontent free: 18072 chunk size:388\r\nsendcontent free: 18040 chunk size:454\r\nsendcontent free: 18088 chunk size:412\r\nsendcontent free: 18112 chunk size:259\r\nsendcontent free: 18112 chunk size:0\r\nRam usage: Webserver only: 344 including Core: 0\r\nsendcontent free: 18184 chunk size:340\r\nWD   : Uptime 35 ConnectFailures 0 FreeMem 18328\r\nsendcontent free: 18184 chunk size:340\r\nEVENT: Clock#Time=Mon,09:41\r\nEVENT: Clock#Time=Mon,09:41 Processing time:91 milliSeconds\r\nsendcontent free: 18184 chunk size:340\r\nWD   : Uptime 35 ConnectFailures 0 FreeMem 18576\r\nsendcontent free: 18184 chunk size:340\r\n```\r\n### System configuration\r\n\r\nHardware:\r\n\r\nSONOFF Basic\r\nSoftware or git version:\r\nBuilt off a git pull from the v2.0 branch on Sunday, March 11th\r\n\r\nSystem |  \r\n-- | --\r\nBuild | 20000\r\nGit Build | \"\"\r\nLocal time | \"2018-03-12 09:40:27\"\r\nUnit | 11\r\nUptime | 34\r\nFree RAM | 18216\r\nSensors |  \r\n0 |  \r\ntasknr | 1\r\nTaskName | \"button\"\r\nType | \"Switch input - Switch\"\r\nstate | 0\r\n1 |  \r\ntasknr | 2\r\nTaskName | \"relay\"\r\nType | \"Switch input - Switch\"\r\nstate | 0\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/letscontrolit/ESPEasy/issues/comments/372289555","html_url":"https://github.com/letscontrolit/ESPEasy/issues/1066#issuecomment-372289555","issue_url":"https://api.github.com/repos/letscontrolit/ESPEasy/issues/1066","id":372289555,"user":{"login":"pljakobs","id":13985375,"avatar_url":"https://avatars1.githubusercontent.com/u/13985375?v=4","gravatar_id":"","url":"https://api.github.com/users/pljakobs","html_url":"https://github.com/pljakobs","followers_url":"https://api.github.com/users/pljakobs/followers","following_url":"https://api.github.com/users/pljakobs/following{/other_user}","gists_url":"https://api.github.com/users/pljakobs/gists{/gist_id}","starred_url":"https://api.github.com/users/pljakobs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pljakobs/subscriptions","organizations_url":"https://api.github.com/users/pljakobs/orgs","repos_url":"https://api.github.com/users/pljakobs/repos","events_url":"https://api.github.com/users/pljakobs/events{/privacy}","received_events_url":"https://api.github.com/users/pljakobs/received_events","type":"User","site_admin":false},"created_at":"2018-03-12T12:14:07Z","updated_at":"2018-03-12T12:14:07Z","author_association":"NONE","body":"I guess this is where it all happens:\r\n\r\n```\r\nvoid sendContentBlocking(String& data) {\r\n  checkRAM(F(\"sendContentBlocking\"));\r\n  uint32_t freeBeforeSend = ESP.getFreeHeap();\r\n  String log = String(\"sendcontent free: \") + freeBeforeSend + \" chunk size:\" + data.length();\r\n  addLog(LOG_LEVEL_DEBUG_DEV, log);\r\n  freeBeforeSend = ESP.getFreeHeap();\r\n  if (TXBuffer.beforeTXRam > freeBeforeSend)\r\n    TXBuffer.beforeTXRam = freeBeforeSend;\r\n  TXBuffer.duringTXRam = freeBeforeSend;\r\n#if defined(ESP8266) && defined(ARDUINO_ESP8266_RELEASE_2_3_0)\r\n  String size = String(data.length(), HEX) + \"\\r\\n\";\r\n  // do chunked transfer encoding ourselves (WebServer doesn't support it)\r\n  WebServer.sendContent(size);\r\n  if (data.length()) WebServer.sendContent(data);\r\n  WebServer.sendContent(\"\\r\\n\");\r\n#else  // ESP8266 2.4.0rc2 and higher and the ESP32 webserver supports chunked http transfer\r\n  unsigned int timeout = 0;\r\n  if (freeBeforeSend < 5000) timeout = 100;\r\n  if (freeBeforeSend < 4000) timeout = 1000;\r\n  const uint32_t beginWait = millis();\r\n  WebServer.sendContent(data);\r\n  while ((ESP.getFreeHeap() < freeBeforeSend) &&\r\n         !timeOutReached(beginWait + timeout)) {\r\n    if (ESP.getFreeHeap() < TXBuffer.duringTXRam)\r\n      TXBuffer.duringTXRam = ESP.getFreeHeap();\r\n    ;\r\n    TXBuffer.trackCoreMem();\r\n    checkRAM(F(\"duringDataTX\"));\r\n    delay(1);\r\n  }\r\n#endif\r\n\r\n  TXBuffer.sentBytes += data.length();\r\n  data = \"\";\r\n}\r\n```\r\nLooks like the debug output would happen whether there's enough free heap or not, although the resulting log shows that there clearly is enough heap.\r\nHere's my PIO environment: I wonder, it states that there would be espressiv 1.5.0 and 1.6.0 environments availalbe, but I'm not sure if either defines ARDUINO_ESP8266_RELEASE_2_3_0?\r\n```\r\nWindows PowerShell\r\nCopyright (C) Microsoft Corporation. Alle Rechte vorbehalten.\r\n\r\nPS C:\\Users\\cn-0f27dt-f1167-1bi-\\Documents\\GitHub\\ESPEasy> platformio update\r\nUpdating tool-scons                      @ 2.20501.4      [Up-to-date]\r\nUpdating tool-unity                      @ 1.20302.1      [Up-to-date]\r\nUUpdating contrib-pysite                  @ 0.1.5\r\n[Up-to-date]\r\nUpdating contrib-piohome                 @ 0.7.1          [0.8.1]\r\nUninstalling contrib-piohome @ 0.7.1:   [[OK]\r\nCorePackageManager: Installing contrib-piohome @ 0.8.1\r\nDownloading...\r\nUnpacking...\r\ncontrib-piohome @ 0.8.1 has been successfully installed!\r\nUpdating tool-pioplus                    @ 0.14.4         [Up-to-date]\r\n\r\n\r\nPlatform Manager\r\n================\r\nPlatform Espressif 8266\r\n--------\r\nUpdating espressif8266                   @ 1.6.0          [Up-to-date]\r\nUpdating tool-esptool                    @ 1.409.0        [Up-to-date]\r\nUUpdating toolchain-xtensa                @ 1.40802.0\r\n[Up-to-date]\r\n\r\nPlatform Espressif 8266\r\n--------\r\nUpdating espressif8266                   @ 1.5.0          [Fixed]\r\nUpdating tool-mkspiffs                   @ 1.102.0        [Up-to-date]\r\nUpdating tool-esptool                    @ 1.409.0        [Up-to-date]\r\nUpdating tool-espotapy                   @ 1.0.0          [Up-to-date]\r\nUpdating framework-arduinoespressif8266  @ 1.20300.1      [Up-to-date]\r\nUpdating toolchain-xtensa                @ 1.40802.0      [Up-to-date]\r\n```\r\n\r\n"}}
{"actor":{"display_login":"pljakobs"}}