AnsweredAssumed Answered

HTTP Server Max Sessions

Question asked by jschepler on May 11, 2018
Latest reply on Jun 6, 2018 by Daniel Chen

I am having issues when first loading the webpage of an embedded webserver.  I think it is due to the amount of TCP connections Chrome is requesting when I first try to load the page.  Please read through my perceived description of the cause/problem and let me know your suggestions.   Thanks.


I am using KSDK 1.3.0 with MQX with a K64F processor.  I am hosting a webserver and have defined the max number of HTTP sessions to 2.  I noticed that when I am trying to load the webpage from a browser it takes 20 seconds for the webpage to initially load.  After it is loaded, there are no issues with the 1 second timeout refresh built-in to the webpage / javascript.


I used wireshark to view the packets.  When I type the webpage into the Chrome, and before hitting enter, Chrome already sends out 6 TCP SYN packets.  I see that the embedded webserver responds to each of the 6 SYN packets with a SYN, ACK.


When I view the task states, there are two "HTTP Server Session" tasks present.


Lets lets say the client uses ports 60001 - 60006 to connect to port 80 of the server.


The webserver, I believe, only keeps the 2 most recent sessions (60005 and 60006).  When I press enter on the address bar, wireshark shows the port of the 1st request from the client is the one requesting the HTTP page (60001).


Since this connection is not established anymore, the webserver waits up to 20 seconds (HTTPSRVCFG_SES_TO) to close 60005/60006 connections due to inactivity.  Once it is closed, then it responds to the 60001 port request.


How should I go about getting the webserver to work faster on the initial load of the page?  Should I re-compile with changing the HTTPSRVCFG_SES_TO to something like 1 second?  I don't really want to set the max number of sessions to 6 because of the limited amount of RAM on the controller.