httpd POST gets stuck after few requests

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

httpd POST gets stuck after few requests

vysocan
I'm bit new to lwip, and I'm using it on STM32407 with ChibiOS which is RTOS. I'm using current stable version of lwip and bindings form ChibiOS to run it as threads. My static and also dynamically generated html pages are served well and without any issues. But I have problem with POST. I use the example post striped down to bare minimum, that is the application does not do any other thing on httpd_post_begin, _receive_data, _finished, then to print the
parameters received.

Now what I;m experiencing is that after few POSTs the whole lwip gets stuck. Curiously enough, it does not get stuck in POST itself but in the sending of subsequent html pages.

Then after few more POSTs I get this from debug:
Opening /index.html
http_recv: data 536926228 len 1420
http_send: pcb=536925064 hs=536926136 left=1420
Trying to send 17 bytes
Sent 17 bytes
Trying to send 63 bytes
Sent 63 bytes
Trying to send 16 bytes
Sent 16 bytes
Trying to send 6 bytes
Sent 6 bytes
Trying to send 27 bytes
Sent 27 bytes
Trying to send 1420 bytes
Sent 1420 bytes
End of file.
Closing connection 536925064
ethernet_output: sending packet p
ethernet_output: sending packet p
etharp_timer
etharp_timer
ethernet_output: sending packet p
etharp_timer
.......
etharp_timer

And the lwip is stuck, not sending the file requested by next GET, while other threads work well. 
Both threads serving lwip, called lwipthread and tcpip_thread are in good state and not over flooded.

Any ideas what can be the cause?

Thanks Adam

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: httpd POST gets stuck after few requests

Trampas Stern
What is the maximum number of connections you have setup? 

Which processor are you using? 

Trampas

On Tue, Feb 4, 2020 at 9:08 AM Adam Baron <[hidden email]> wrote:
I'm bit new to lwip, and I'm using it on STM32407 with ChibiOS which is RTOS. I'm using current stable version of lwip and bindings form ChibiOS to run it as threads. My static and also dynamically generated html pages are served well and without any issues. But I have problem with POST. I use the example post striped down to bare minimum, that is the application does not do any other thing on httpd_post_begin, _receive_data, _finished, then to print the
parameters received.

Now what I;m experiencing is that after few POSTs the whole lwip gets stuck. Curiously enough, it does not get stuck in POST itself but in the sending of subsequent html pages.

Then after few more POSTs I get this from debug:
Opening /index.html
http_recv: data 536926228 len 1420
http_send: pcb=536925064 hs=536926136 left=1420
Trying to send 17 bytes
Sent 17 bytes
Trying to send 63 bytes
Sent 63 bytes
Trying to send 16 bytes
Sent 16 bytes
Trying to send 6 bytes
Sent 6 bytes
Trying to send 27 bytes
Sent 27 bytes
Trying to send 1420 bytes
Sent 1420 bytes
End of file.
Closing connection 536925064
ethernet_output: sending packet p
ethernet_output: sending packet p
etharp_timer
etharp_timer
ethernet_output: sending packet p
etharp_timer
.......
etharp_timer

And the lwip is stuck, not sending the file requested by next GET, while other threads work well. 
Both threads serving lwip, called lwipthread and tcpip_thread are in good state and not over flooded.

Any ideas what can be the cause?

Thanks Adam
_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: httpd POST gets stuck after few requests

vysocan
Not sure which parameter is defining maximum number of connections.
Processor is ARM 32bit STM32F407.

út 4. 2. 2020 v 15:38 odesílatel Trampas Stern <[hidden email]> napsal:
What is the maximum number of connections you have setup? 

Which processor are you using? 

Trampas

On Tue, Feb 4, 2020 at 9:08 AM Adam Baron <[hidden email]> wrote:
I'm bit new to lwip, and I'm using it on STM32407 with ChibiOS which is RTOS. I'm using current stable version of lwip and bindings form ChibiOS to run it as threads. My static and also dynamically generated html pages are served well and without any issues. But I have problem with POST. I use the example post striped down to bare minimum, that is the application does not do any other thing on httpd_post_begin, _receive_data, _finished, then to print the
parameters received.

Now what I;m experiencing is that after few POSTs the whole lwip gets stuck. Curiously enough, it does not get stuck in POST itself but in the sending of subsequent html pages.

Then after few more POSTs I get this from debug:
Opening /index.html
http_recv: data 536926228 len 1420
http_send: pcb=536925064 hs=536926136 left=1420
Trying to send 17 bytes
Sent 17 bytes
Trying to send 63 bytes
Sent 63 bytes
Trying to send 16 bytes
Sent 16 bytes
Trying to send 6 bytes
Sent 6 bytes
Trying to send 27 bytes
Sent 27 bytes
Trying to send 1420 bytes
Sent 1420 bytes
End of file.
Closing connection 536925064
ethernet_output: sending packet p
ethernet_output: sending packet p
etharp_timer
etharp_timer
ethernet_output: sending packet p
etharp_timer
.......
etharp_timer

And the lwip is stuck, not sending the file requested by next GET, while other threads work well. 
Both threads serving lwip, called lwipthread and tcpip_thread are in good state and not over flooded.

Any ideas what can be the cause?

Thanks Adam
_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users


--
731435556
Adam Baron

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: httpd POST gets stuck after few requests

vysocan
OK, so my lwip gets stuck exactly after 16 POSTs.

Maybe the POST is not freeing PCB, or other structures properly.

And I have overridden these out of default:
#define MEMP_NUM_SYS_TIMEOUT (LWIP_NUM_SYS_TIMEOUT_INTERNAL + 3)
#define MEMP_NUM_UDP_PCB 6
#define MEMP_NUM_TCP_PCB 6
#define MEMP_NUM_TCP_PCB_LISTEN 10
#define MEMP_NUM_PBUF 20
#define MEMP_NUM_RAW_PCB 6
// Maximum segment size
#define TCP_MSS 1024
// Number of rx pbufs to enqueue to parse an incoming request (up to the first newline)
#define LWIP_HTTPD_REQ_QUEUELEN 7

Adam

út 4. 2. 2020 v 16:29 odesílatel Adam Baron <[hidden email]> napsal:
Not sure which parameter is defining maximum number of connections.
Processor is ARM 32bit STM32F407.

út 4. 2. 2020 v 15:38 odesílatel Trampas Stern <[hidden email]> napsal:
What is the maximum number of connections you have setup? 

Which processor are you using? 

Trampas

On Tue, Feb 4, 2020 at 9:08 AM Adam Baron <[hidden email]> wrote:
I'm bit new to lwip, and I'm using it on STM32407 with ChibiOS which is RTOS. I'm using current stable version of lwip and bindings form ChibiOS to run it as threads. My static and also dynamically generated html pages are served well and without any issues. But I have problem with POST. I use the example post striped down to bare minimum, that is the application does not do any other thing on httpd_post_begin, _receive_data, _finished, then to print the
parameters received.

Now what I;m experiencing is that after few POSTs the whole lwip gets stuck. Curiously enough, it does not get stuck in POST itself but in the sending of subsequent html pages.

Then after few more POSTs I get this from debug:
Opening /index.html
http_recv: data 536926228 len 1420
http_send: pcb=536925064 hs=536926136 left=1420
Trying to send 17 bytes
Sent 17 bytes
Trying to send 63 bytes
Sent 63 bytes
Trying to send 16 bytes
Sent 16 bytes
Trying to send 6 bytes
Sent 6 bytes
Trying to send 27 bytes
Sent 27 bytes
Trying to send 1420 bytes
Sent 1420 bytes
End of file.
Closing connection 536925064
ethernet_output: sending packet p
ethernet_output: sending packet p
etharp_timer
etharp_timer
ethernet_output: sending packet p
etharp_timer
.......
etharp_timer

And the lwip is stuck, not sending the file requested by next GET, while other threads work well. 
Both threads serving lwip, called lwipthread and tcpip_thread are in good state and not over flooded.

Any ideas what can be the cause?

Thanks Adam
_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users


--
731435556
Adam Baron


--
731435556
Adam Baron

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: httpd POST gets stuck after few requests

Trampas Stern
In reply to this post by vysocan
/**
 * MEMP_NUM_TCP_PCB: the number of simulatenously active TCP connections.
 * (requires the LWIP_TCP option)
 */
#define MEMP_NUM_TCP_PCB                10

/**
 * MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP connections.
 * (requires the LWIP_TCP option)
 */
#define MEMP_NUM_TCP_PCB_LISTEN        4

I personally have found that to use Chrome I need at least 6 TCP connections as it opens new connection for each of the CSS files. 

Also with the STM32 their drivers for the PHY chips have some bugs. 

I do not use the STM32, but be careful if the GMAC driver does DMA transfers as you may need to turn off data cache  on the core. 


 

On Tue, Feb 4, 2020 at 10:30 AM Adam Baron <[hidden email]> wrote:
Not sure which parameter is defining maximum number of connections.
Processor is ARM 32bit STM32F407.

út 4. 2. 2020 v 15:38 odesílatel Trampas Stern <[hidden email]> napsal:
What is the maximum number of connections you have setup? 

Which processor are you using? 

Trampas

On Tue, Feb 4, 2020 at 9:08 AM Adam Baron <[hidden email]> wrote:
I'm bit new to lwip, and I'm using it on STM32407 with ChibiOS which is RTOS. I'm using current stable version of lwip and bindings form ChibiOS to run it as threads. My static and also dynamically generated html pages are served well and without any issues. But I have problem with POST. I use the example post striped down to bare minimum, that is the application does not do any other thing on httpd_post_begin, _receive_data, _finished, then to print the
parameters received.

Now what I;m experiencing is that after few POSTs the whole lwip gets stuck. Curiously enough, it does not get stuck in POST itself but in the sending of subsequent html pages.

Then after few more POSTs I get this from debug:
Opening /index.html
http_recv: data 536926228 len 1420
http_send: pcb=536925064 hs=536926136 left=1420
Trying to send 17 bytes
Sent 17 bytes
Trying to send 63 bytes
Sent 63 bytes
Trying to send 16 bytes
Sent 16 bytes
Trying to send 6 bytes
Sent 6 bytes
Trying to send 27 bytes
Sent 27 bytes
Trying to send 1420 bytes
Sent 1420 bytes
End of file.
Closing connection 536925064
ethernet_output: sending packet p
ethernet_output: sending packet p
etharp_timer
etharp_timer
ethernet_output: sending packet p
etharp_timer
.......
etharp_timer

And the lwip is stuck, not sending the file requested by next GET, while other threads work well. 
Both threads serving lwip, called lwipthread and tcpip_thread are in good state and not over flooded.

Any ideas what can be the cause?

Thanks Adam
_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users


--
731435556
Adam Baron
_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: httpd POST gets stuck after few requests

goldsimon@gmx.de
In reply to this post by vysocan


Adam Baron wrote:
>OK, so my lwip gets stuck exactly after 16 POSTs.
>
>Maybe the POST is not freeing PCB, or other structures properly.

I rather think not freeing a pbuf could be the cause. I think we had that a little while ago. Have you searched the list archive?

Regards,
Simon

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: httpd POST gets stuck after few requests

vysocan
I did search of POST related problems sorted by date. I will do so again.

PBUF_POOL_SIZE is affecting number of POST I can do directly. That is, I can do as many posts as PBUF_POOL_SIZE is defined.

@Trampas SternI hope it is not something in STM32 itself.

út 4. 2. 2020 v 17:18 odesílatel goldsimon <[hidden email]> napsal:


Adam Baron wrote:
>OK, so my lwip gets stuck exactly after 16 POSTs.
>
>Maybe the POST is not freeing PCB, or other structures properly.

I rather think not freeing a pbuf could be the cause. I think we had that a little while ago. Have you searched the list archive?

Regards,
Simon

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users


--
731435556
Adam Baron

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: httpd POST gets stuck after few requests

goldsimon@gmx.de


Adam Baron wrote:
>I did search of POST related problems sorted by date. I will do so
>again.
>
>PBUF_POOL_SIZE is affecting number of POST I can do directly. That is,
>I
>can do as many posts as PBUF_POOL_SIZE is defined.

I think the user reporting this last time,did not free the pbuf passed to the post start callback, but I could remember wrong...

Regards,
Simon

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: httpd POST gets stuck after few requests

Trampas Stern
err_t httpd_post_receive_data(void *connection, struct pbuf *p)
{
 pbuf_free(p);
return ERR_OK;
}


On Tue, Feb 4, 2020 at 11:35 AM goldsimon <[hidden email]> wrote:


Adam Baron wrote:
>I did search of POST related problems sorted by date. I will do so
>again.
>
>PBUF_POOL_SIZE is affecting number of POST I can do directly. That is,
>I
>can do as many posts as PBUF_POOL_SIZE is defined.

I think the user reporting this last time,did not free the pbuf passed to the post start callback, but I could remember wrong...

Regards,
Simon

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: httpd POST gets stuck after few requests

vysocan
In reply to this post by goldsimon@gmx.de
I followed the contrib-2.1.0/examples/httpd/post_example/post_example.c, I did not notice any free of pbuf there.

I guess if application is responsible for pbuf free then only httpd_post_receive_data() is candidate as it has pointer to data pbuf as parameter?


út 4. 2. 2020 v 17:36 odesílatel goldsimon <[hidden email]> napsal:


Adam Baron wrote:
>I did search of POST related problems sorted by date. I will do so
>again.
>
>PBUF_POOL_SIZE is affecting number of POST I can do directly. That is,
>I
>can do as many posts as PBUF_POOL_SIZE is defined.

I think the user reporting this last time,did not free the pbuf passed to the post start callback, but I could remember wrong...

Regards,
Simon

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users


--
731435556
Adam Baron

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: httpd POST gets stuck after few requests

goldsimon@gmx.de
In reply to this post by Trampas Stern


Trampas Stern wrote:
>err_t httpd_post_receive_data(void *connection, struct pbuf *p)
>{
> pbuf_free(p);
>return ERR_OK;
>}

Ah, yes. And the problem still is that the example does not do that. I'll file a bug...

Regards,
Simon

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: httpd POST gets stuck after few requests

vysocan
In reply to this post by vysocan
I found some info in httpd.c that has call to httpd_post_receive_data()

/** Pass received POST body data to the application and correctly handle
 * returning a response document or closing the connection.
 * ATTENTION: The application is responsible for the pbuf now, so don't free it!
 *
 * @param hs http connection state
 * @param p pbuf to pass to the application
 * @return ERR_OK if passed successfully, another err_t if the response file
 *         hasn't been found (after POST finished)
 */
static err_t
http_post_rxpbuf(struct http_state *hs, struct pbuf *p)

I guess, now I have to find out how to free pbuf.

út 4. 2. 2020 v 17:46 odesílatel Adam Baron <[hidden email]> napsal:
I followed the contrib-2.1.0/examples/httpd/post_example/post_example.c, I did not notice any free of pbuf there.

I guess if application is responsible for pbuf free then only httpd_post_receive_data() is candidate as it has pointer to data pbuf as parameter?


út 4. 2. 2020 v 17:36 odesílatel goldsimon <[hidden email]> napsal:


Adam Baron wrote:
>I did search of POST related problems sorted by date. I will do so
>again.
>
>PBUF_POOL_SIZE is affecting number of POST I can do directly. That is,
>I
>can do as many posts as PBUF_POOL_SIZE is defined.

I think the user reporting this last time,did not free the pbuf passed to the post start callback, but I could remember wrong...

Regards,
Simon

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users


--
731435556
Adam Baron


--
731435556
Adam Baron

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: httpd POST gets stuck after few requests

vysocan
In reply to this post by goldsimon@gmx.de
Added "if (p != NULL) pbuf_free(p);" to the httpd_post_receive_data() and works like a charm.

Thank you all.

út 4. 2. 2020 v 17:49 odesílatel goldsimon <[hidden email]> napsal:


Trampas Stern wrote:
>err_t httpd_post_receive_data(void *connection, struct pbuf *p)
>{
> pbuf_free(p);
>return ERR_OK;
>}

Ah, yes. And the problem still is that the example does not do that. I'll file a bug...

Regards,
Simon

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users


--
731435556
Adam Baron

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users