{"action":"created","issue":{"url":"https://api.github.com/repos/chmorgan/libesphttpd/issues/41","repository_url":"https://api.github.com/repos/chmorgan/libesphttpd","labels_url":"https://api.github.com/repos/chmorgan/libesphttpd/issues/41/labels{/name}","comments_url":"https://api.github.com/repos/chmorgan/libesphttpd/issues/41/comments","events_url":"https://api.github.com/repos/chmorgan/libesphttpd/issues/41/events","html_url":"https://github.com/chmorgan/libesphttpd/issues/41","id":364561326,"node_id":"MDU6SXNzdWUzNjQ1NjEzMjY=","number":41,"title":"httpd hangs after browser request","user":{"login":"phatpaul","id":3495287,"node_id":"MDQ6VXNlcjM0OTUyODc=","avatar_url":"https://avatars3.githubusercontent.com/u/3495287?v=4","gravatar_id":"","url":"https://api.github.com/users/phatpaul","html_url":"https://github.com/phatpaul","followers_url":"https://api.github.com/users/phatpaul/followers","following_url":"https://api.github.com/users/phatpaul/following{/other_user}","gists_url":"https://api.github.com/users/phatpaul/gists{/gist_id}","starred_url":"https://api.github.com/users/phatpaul/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phatpaul/subscriptions","organizations_url":"https://api.github.com/users/phatpaul/orgs","repos_url":"https://api.github.com/users/phatpaul/repos","events_url":"https://api.github.com/users/phatpaul/events{/privacy}","received_events_url":"https://api.github.com/users/phatpaul/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-09-27T16:41:09Z","updated_at":"2018-09-27T21:10:24Z","closed_at":null,"author_association":"NONE","body":"I'm developing a product using libesphttpd.  I'm serving 5~15 static files (html, js, css) on the browser initial load.  I'm also serving a couple of simple cgi functions.\r\n\r\nI've got most everything working for a demonstration in a couple days, but I have a critical bug.  Please help!\r\n\r\nThe httpd server seems to hang occasionally for several minutes.  It most often happens during an initial load of the static files.\r\n\r\nThe ESP still responds to PING while the httpd is frozen.\r\n\r\nSometimes, After several minutes (>20min) of hanging, I see error messages on the console like this: (but sometimes it seems to hang indefinitely)\r\n```\r\nE (6791432) httpd: send buf tried to write 1032 bytes, wrote -1\r\nE (6791432) httpd-freertos: accept failed\r\naccept: Socket is not connected\r\nE (6791482) httpd: send buf tried to write 1032 bytes, wrote -1\r\n```\r\n\r\nWireshark shows that the /static/plugins/jquery.min.js file was starting to transfer, but never finishes.  There are just a bunch of TCP Keep-Alives after the last TCP segment is received.  \r\n\r\nTCPView shows that there are still 7 TCP connections from firefox to the ESP.  All are ESTABLISHED, except one is FIN_WAIT2.  (but the connection that seems to have stalled is listed as ESTABLISHED)\r\n\r\nI've hooked-up the JTAG debugger and see that it is stuck in a function.  I'll post that info shortly.\r\n\r\nI've tried many things to isolate the problem, but it persists:\r\n\r\n- I served static files using the built-in espfs.  \r\n- I served static files using vfs-fat filesystem.  (it seems to hang even more often with this method)\r\n- I compressed the static files using uglifyjs and yui-compressor.\r\n- I just served a single html file as a test.  The hang happens much less often, but still occurred.\r\n- I tried with Ethernet and Wifi STA - seems the same occurrence of hangs.  Wifi AP mode seems to cause it to hang every time.\r\n\r\n- I have adjusted the following compile options (I've tried several combinations of these settings, to no avail):\r\n(especially the Wifi and ethernet buffer sizes) \r\n[sdkconfig.txt](https://github.com/chmorgan/libesphttpd/files/2424786/sdkconfig.txt)\r\n\r\nCONFIG_OPTIMIZATION_LEVEL_RELEASE=y\r\nCONFIG_STACK_CHECK=y\r\nCONFIG_STACK_CHECK_NORM=y\r\nCONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ=240\r\nCONFIG_SPIRAM_BOOT_INIT=y\r\nCONFIG_SPIRAM_IGNORE_NOTFOUND=y\r\nCONFIG_SPIRAM_USE_MEMMAP=\r\nCONFIG_SPIRAM_USE_CAPS_ALLOC=\r\nCONFIG_SPIRAM_USE_MALLOC=y\r\nCONFIG_SPIRAM_TYPE_ESPPSRAM32=y\r\nCONFIG_SPIRAM_SIZE=4194304\r\nCONFIG_SPIRAM_SPEED_40M=y\r\nCONFIG_SPIRAM_MEMTEST=y\r\nCONFIG_SPIRAM_CACHE_WORKAROUND=\r\nCONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=16384\r\nCONFIG_WIFI_LWIP_ALLOCATION_FROM_SPIRAM_FIRST=y\r\nCONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=32768\r\nCONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY=y\r\nCONFIG_TASK_WDT_TIMEOUT_S=15\r\nCONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=16\r\nCONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=16\r\nCONFIG_ESP32_WIFI_STATIC_TX_BUFFER=y\r\nCONFIG_ESP32_WIFI_TX_BUFFER_TYPE=0\r\nCONFIG_ESP32_WIFI_STATIC_TX_BUFFER_NUM=16\r\nCONFIG_EMAC_L2_TO_L3_RX_BUF_MODE=y\r\n\r\nCONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS=4\r\nCONFIG_FREERTOS_ISR_STACKSIZE=4096\r\nCONFIG_SUPPORT_STATIC_ALLOCATION=y\r\n\r\nCONFIG_ESPHTTPD_STACK_SIZE=8192\r\nCONFIG_ESPHTTPD_SO_REUSEADDR=y\r\nCONFIG_ESPHTTPD_SANITIZE_URLS=y\r\n#\r\n# LWIP\r\n#\r\nCONFIG_L2_TO_L3_COPY=y\r\nCONFIG_LWIP_MAX_SOCKETS=16\r\nCONFIG_LWIP_IP_REASSEMBLY=y\r\nCONFIG_LWIP_STATS=y\r\nCONFIG_ESP_GRATUITOUS_ARP=y\r\nCONFIG_GARP_TMR_INTERVAL=60\r\n#\r\n# UDP\r\n#\r\nCONFIG_TCPIP_TASK_STACK_SIZE=4096"},"comment":{"url":"https://api.github.com/repos/chmorgan/libesphttpd/issues/comments/425244323","html_url":"https://github.com/chmorgan/libesphttpd/issues/41#issuecomment-425244323","issue_url":"https://api.github.com/repos/chmorgan/libesphttpd/issues/41","id":425244323,"node_id":"MDEyOklzc3VlQ29tbWVudDQyNTI0NDMyMw==","user":{"login":"Si03","id":18641822,"node_id":"MDQ6VXNlcjE4NjQxODIy","avatar_url":"https://avatars3.githubusercontent.com/u/18641822?v=4","gravatar_id":"","url":"https://api.github.com/users/Si03","html_url":"https://github.com/Si03","followers_url":"https://api.github.com/users/Si03/followers","following_url":"https://api.github.com/users/Si03/following{/other_user}","gists_url":"https://api.github.com/users/Si03/gists{/gist_id}","starred_url":"https://api.github.com/users/Si03/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Si03/subscriptions","organizations_url":"https://api.github.com/users/Si03/orgs","repos_url":"https://api.github.com/users/Si03/repos","events_url":"https://api.github.com/users/Si03/events{/privacy}","received_events_url":"https://api.github.com/users/Si03/received_events","type":"User","site_admin":false},"created_at":"2018-09-27T21:10:24Z","updated_at":"2018-09-27T21:10:24Z","author_association":"NONE","body":"@phatpaul I have a very similar setup to you, this library, LAN8270, wifi, and UART, maybe less files per page but a fair bit of json moving about via cgi and it's working fine. I have seen the same error during development though (wrote -1) and can't remember for the time being exactly what it was. Are you using the basic authentication at all? I do know that was a problem in relation to cgi calls. Also had some issues with cross site cgi and authentication because even in a different folder they are deemed cross-site. You have to enable cors via menuconfig.\r\nNot a lot of help, sorry.\r\nSi."}}
{"actor":{"display_login":"Si03"}}