• AVR Freaks

AnsweredIssues with webpages loading slowly sometimes with Harmony

Author
AAtencio
New Member
  • Total Posts : 26
  • Reward points : 0
  • Joined: 2014/06/11 13:14:32
  • Location: 0
  • Status: offline
2017/06/06 08:02:36 (permalink)
0

Issues with webpages loading slowly sometimes with Harmony

I'm using harmony version 10, I have a pic32mz2048efh144.
 
I'm having an issue with my webpages not loading all the time.
I seem to display the web pages just fine some of the time, but sometimes (about 1 in 4 times that I load a page) the pages take a long time to load (a minute or longer) and comes back missing data sometimes(page half there).
 
I tossed some break points around. When I get the bad pages the TCPIP_HTTP_Process() in http.c seems to be triggering the if(TCPIP_TCP_WasReset(pHttpCon->socket)) check after a bit.
The Reset seems to be caused in tcp.c by these lines:
// Process 2MSL timer
            if(pSkt->smState == TCPIP_TCP_STATE_TIME_WAIT)
            {
                if((int32_t)(SYS_TMR_TickCountGet() - pSkt->closeWaitTime) >= 0)
                { // timeout expired, close the socket
                    _TcpCloseSocket(pSkt, 0);
                    continue;
                }
            }

 
My configuration settings for HTTP and TCP are as follows:
 
/*** HTTP Configuration ***/
#define TCPIP_STACK_USE_HTTP_SERVER
#define TCPIP_HTTP_MAX_HEADER_LEN        40
#define TCPIP_HTTP_CACHE_LEN            "600"
#define TCPIP_HTTP_TIMEOUT                100
#define TCPIP_HTTP_MAX_CONNECTIONS        4
#define TCPIP_HTTP_MAX_TLS_CONNECTIONS      0
#define TCPIP_HTTP_DEFAULT_FILE            "index.htm"
#define TCPIP_HTTPS_DEFAULT_FILE           "index.htm"
#define TCPIP_HTTP_DEFAULT_LEN            10
#define TCPIP_HTTP_MAX_DATA_LEN            240
#define TCPIP_HTTP_MIN_CALLBACK_FREE    16
#define TCPIP_HTTP_SKT_TX_BUFF_SIZE        0
#define TCPIP_HTTP_SKT_RX_BUFF_SIZE        0
#define TCPIP_HTTP_TLS_SKT_TX_BUFF_SIZE                  0
#define TCPIP_HTTP_TLS_SKT_RX_BUFF_SIZE                  0
#define TCPIP_HTTP_CONFIG_FLAGS            1
#define TCPIP_HTTP_USE_POST
#define TCPIP_HTTP_USE_COOKIES
#define TCPIP_HTTP_USE_BASE64_DECODE
#define TCPIP_HTTP_USE_AUTHENTICATION
#define TCPIP_HTTP_TASK_RATE     33
 
/*** TCP Configuration ***/
#define TCPIP_TCP_MAX_SEG_SIZE_TX           8000
#define TCPIP_TCP_MAX_SEG_SIZE_RX_LOCAL        1460
#define TCPIP_TCP_MAX_SEG_SIZE_RX_NON_LOCAL   1460
#define TCPIP_TCP_SOCKET_DEFAULT_TX_SIZE   1024
#define TCPIP_TCP_SOCKET_DEFAULT_RX_SIZE   1024
#define TCPIP_TCP_DYNAMIC_OPTIONS                true
#define TCPIP_TCP_START_TIMEOUT_VAL           1000
#define TCPIP_TCP_DELAYED_ACK_TIMEOUT        100
#define TCPIP_TCP_FIN_WAIT_2_TIMEOUT        5000
#define TCPIP_TCP_KEEP_ALIVE_TIMEOUT        10000
#define TCPIP_TCP_CLOSE_WAIT_TIMEOUT        200
#define TCPIP_TCP_MAX_RETRIES                5
#define TCPIP_TCP_MAX_UNACKED_KEEP_ALIVES   6
#define TCPIP_TCP_MAX_SYN_RETRIES           3
#define TCPIP_TCP_AUTO_TRANSMIT_TIMEOUT_VAL   40
#define TCPIP_TCP_WINDOW_UPDATE_TIMEOUT_VAL   200
#define TCPIP_TCP_MAX_SOCKETS                  10
#define TCPIP_TCP_TASK_TICK_RATE           5
#define TCPIP_TCP_MSL_TIMEOUT               30
#define TCPIP_TCP_QUIET_TIME               0
 
Not sure what to do to fix this issue. Any help would be appreciated.
 
#1
rainad
Moderator
  • Total Posts : 1480
  • Reward points : 0
  • Joined: 2009/05/01 13:39:25
  • Location: 0
  • Status: online
Re: Issues with webpages loading slowly sometimes with Harmony 2017/06/06 08:09:33 (permalink) ☼ Best Answerby AAtencio 2017/06/08 14:50:13
4 (2)
You need to change:
#define TCPIP_TCP_MSL_TIMEOUT               30
to
#define TCPIP_TCP_MSL_TIMEOUT               0
Or increase the number of HTTP sockets.
The browser tries to open multiple sockets. If the sockets on the server side are in the MSL timeout state, they will be unavailable for that time - therefore the slow response.
 
#2
AAtencio
New Member
  • Total Posts : 26
  • Reward points : 0
  • Joined: 2014/06/11 13:14:32
  • Location: 0
  • Status: offline
Re: Issues with webpages loading slowly sometimes with Harmony 2017/06/06 08:58:11 (permalink)
0
Ok, that helped some, but I think we might be fixing symptoms and not the problem.
 
TCPIP_TCP_MSL_TIMEOUT  is now 5 (tried 0 but it wouldn't connect at all)
 
Tried increasing TCPIP_HTTP_MAX_CONNECTIONS from 4 to 8 or 6, wouldn't connect when I did this. I assume there is something else I need to change to get this to work (my max tcpip connections is at 10 so don't think it's that)
 
With the timeout at 5, the bad pages load quicker (about 10 seconds instead of a minute), but It's still a noticeable slow down, and I'm still getting some missing data (pages sometime end up looking funny/half loaded, once or twice failed to load all together)
 
 
#3
rainad
Moderator
  • Total Posts : 1480
  • Reward points : 0
  • Joined: 2009/05/01 13:39:25
  • Location: 0
  • Status: online
Re: Issues with webpages loading slowly sometimes with Harmony 2017/06/06 10:30:17 (permalink)
0
No, TCPIP_TCP_MSL_TIMEOUT should be 0, as I suggested.
Maybe there's something else that's not properly configured.
I notice:
#define TCPIP_TCP_MAX_SEG_SIZE_TX           8000 ??? this is really weird.
I suggest you start with an out of the box demo and get it running. After that you can adjust the parameters.
 
 
#4
AAtencio
New Member
  • Total Posts : 26
  • Reward points : 0
  • Joined: 2014/06/11 13:14:32
  • Location: 0
  • Status: offline
Re: Issues with webpages loading slowly sometimes with Harmony 2017/06/08 14:49:55 (permalink)
0
#define TCPIP_TCP_MAX_SEG_SIZE_TX is now 1460
 
#define TCPIP_TCP_MSL_TIMEOUT is now 0 and seems to work at that level.
 
Thanks
 
 
 
 
 
#5
Stri
Super Member
  • Total Posts : 194
  • Reward points : 0
  • Joined: 2008/03/24 04:10:00
  • Location: Russia, Nsk
  • Status: offline
Re: Issues with webpages loading slowly sometimes with Harmony 2018/09/02 20:03:33 (permalink)
0
I have exactly same problems with my web page, despite my TCPIP_TCP_MSL_TIMEOUT was 0 and TCPIP_TCP_MAX_SEG_SIZE_TX was 1460 from the beginning. Is there something else I could check?

Let's telegram! t.me/microchip_forum
#6
moser
Super Member
  • Total Posts : 637
  • Reward points : 0
  • Joined: 2015/06/16 02:53:47
  • Location: Germany
  • Status: online
Re: Issues with webpages loading slowly sometimes with Harmony 2018/09/04 02:15:26 (permalink)
5 (1)
I would like to ask, is it possible that such problems are also caused by insufficient memory settings?
 
MPLAB Harmony Configurator > TCPIP Stack > Select Heap Configuration > TCP\IP Stack Dynamic RAM Size
MPLAB Harmony Configurator > Device & Project Configuration > Project Configuration > XC32 (Global Options) > General > Heap Size (bytes)
Project Window > Properties > Conf > XC32 (Global Options) > xc32-ld > Heap size (bytes)
 
 
 
 
#7
rainad
Moderator
  • Total Posts : 1480
  • Reward points : 0
  • Joined: 2009/05/01 13:39:25
  • Location: 0
  • Status: online
Re: Issues with webpages loading slowly sometimes with Harmony 2018/09/04 13:57:01 (permalink)
0
You'll notice some delays/interruptions if you're running out of memory.
But different than the issue with the socket timeout.
When running into a temporary out of memory condition, it will continue to work, although it won't be probably possible to keep up with high rate traffic.
You should check that the memory allocation runs in out of memory condition - either from the console or from within the program.
 
 
#8
Jump to:
© 2021 APG vNext Commercial Version 4.5