wifi: bcn_timout,ap_probe_send_start

Dig Kleppe
Posts: 26
Joined: Wed Jun 28, 2017 5:03 pm

wifi: bcn_timout,ap_probe_send_start

Postby Dig Kleppe » Sat Oct 28, 2017 1:16 pm

Hi
I encounter this problem after about 50 (CGI) messages from my webserver.

Code: Select all

I (46012) wifi: bcn_timout,ap_probe_send_start
I (48512) wifi: ap_probe_send over, resett wifi status to disassoc
I (48512) wifi: state: run -> init (1)
I (48522) wifi: pm stop, total sleep time: 0/43754230
I (48522) wifi: n:6 0, o:6 0, ap:255 255, sta:6 0, prof:1
I (168492) event: station ip lost
I see a lot of posts about this error. No solutions yet. I use the latest idf (oct 2017)
When this happens i cannot reconnect. I cannot easy stop the http server in the middle of a action.
It happens in station and AP mode.
How to solve this?
I included my code. It contains a build-in webpage.
Dig
Last edited by Dig Kleppe on Tue Oct 31, 2017 7:06 pm, edited 1 time in total.

Dig Kleppe
Posts: 26
Joined: Wed Jun 28, 2017 5:03 pm

Re: wifi: bcn_timout,ap_probe_send_start

Postby Dig Kleppe » Tue Oct 31, 2017 7:04 pm

I have set a socket timeout to the http server task, so it ends when the connection is broken.
After SYSTEM_EVENT_STA_DISCONNECTED esp_wifi_connect() is called but the connection does not get established again. I also tried to call this from another task. ( see my code)
How now?
It is a stupid question, but did anyone succeed in building a simple webserver? (none- arduino, plain eclipse)
I expected one to be present in the examples.
Dig
Attachments
Webserver.zip
(261.22 KiB) Downloaded 612 times

Dig Kleppe
Posts: 26
Joined: Wed Jun 28, 2017 5:03 pm

Re: wifi: bcn_timout,ap_probe_send_start

Postby Dig Kleppe » Tue Dec 05, 2017 7:27 pm

Hi
This post answers my problem:
https://github.com/espressif/esp-idf/issues/784
Adding netconn_free() after netconn_delete() .
It runs ok now .
Dig

pratik.yadav.455
Posts: 23
Joined: Thu Oct 26, 2017 7:34 am

Re: wifi: bcn_timout,ap_probe_send_start

Postby pratik.yadav.455 » Thu Dec 07, 2017 12:09 pm

hello @ Dig Kleppe,

Facing same issue in my http server.
I am using esp32 In AP mode. After sending certain requests my server stop accepting new request.

I don't use receiving timeout for server socket. just use receiving timeout for client socket.

my http server (esp32) stop responding after number of requests.

When i Reconnect with my http server, i can't connect to my http server.

I used modified file of api_lib.c.

Any suggestion why this is happening?

Dig Kleppe
Posts: 26
Joined: Wed Jun 28, 2017 5:03 pm

Re: wifi: bcn_timout,ap_probe_send_start

Postby Dig Kleppe » Thu Dec 07, 2017 6:30 pm

Hi Pratikm
I dont know what kind of server you use, but if its netconn based the additon of netconn_free solves the memoryleak;
My server task:

Code: Select all

while (1) {

void HTTPServerTask(void *pvParameters) {
	struct netconn *conn, *newconn;
	err_t err = ERR_OK;
	while (1) {
		while (!gotIP || !isConnected)
			vTaskDelay(10);
		conn = netconn_new(NETCONN_TCP);
		netconn_bind(conn, NULL, 80);
		netconn_listen(conn);
		do {
			err = netconn_accept(conn, &newconn);
			if (err == ERR_OK) {
				httpServerServe(newconn);
				netconn_close(newconn);
				netconn_delete(newconn);
				netconn_free(newconn);
			}
		} while (err == ERR_OK);
		netconn_close(conn);
		netconn_delete(conn);
		netconn_free(conn);
	}
}
If you have a socket based server you have to dig further into the LWIP code. Probably the sockets also use netconns,

By the way:
Because of lack of memory when in trouble the reconnect did not work, only rebooting ...

pratik.yadav.455
Posts: 23
Joined: Thu Oct 26, 2017 7:34 am

Re: wifi: bcn_timout,ap_probe_send_start

Postby pratik.yadav.455 » Fri Dec 08, 2017 11:25 am

Dig Kleppe wrote:Hi Pratikm
I dont know what kind of server you use, but if its netconn based the additon of netconn_free solves the memoryleak;
My server task:

Code: Select all

while (1) {

void HTTPServerTask(void *pvParameters) {
	struct netconn *conn, *newconn;
	err_t err = ERR_OK;
	while (1) {
		while (!gotIP || !isConnected)
			vTaskDelay(10);
		conn = netconn_new(NETCONN_TCP);
		netconn_bind(conn, NULL, 80);
		netconn_listen(conn);
		do {
			err = netconn_accept(conn, &newconn);
			if (err == ERR_OK) {
				httpServerServe(newconn);
				netconn_close(newconn);
				netconn_delete(newconn);
				netconn_free(newconn);
			}
		} while (err == ERR_OK);
		netconn_close(conn);
		netconn_delete(conn);
		netconn_free(conn);
	}
}
If you have a socket based server you have to dig further into the LWIP code. Probably the sockets also use netconns,

By the way:
Because of lack of memory when in trouble the reconnect did not work, only rebooting ...

Thnaks for quick response,
Yes i have used netcon API to create server, and also socket internally use netconn API.

Code: Select all

static void http_server(void *pvParameters)
{
	
  ESP_LOGI(TAG,"system_get_free_heap_size in starting of server task =%d\n\n\n",system_get_free_heap_size());
  struct netconn *conn , *newconn;
 
  err_t err,err_listen,err_accept;
  conn = netconn_new(NETCONN_TCP);
  uint32_t total=0;
  uint32_t used=0;
	
  
  if(conn!=NULL)
    {
 
	  err= netconn_bind(conn, NULL, 80);
	   if (err == ERR_OK)
	   ESP_LOGI(TAG,"socket bound");
	   
	  err_listen=netconn_listen(conn);
	  
	  if(err_listen==ERR_OK)
	  {
		
		  do{
					
			
				ESP_LOGI(TAG,"system_get_free_heap_size before accept in request number %d =%d",++counter,system_get_free_heap_size());
				ESP_LOGI(TAG,"system_get_time before accept in request number %d =%d",++counter,system_get_time());
				err_accept = netconn_accept(conn, &newconn);
				
				if (err_accept == ERR_OK)
				{
					ESP_LOGI(TAG,"connection accept\n");
					
					ESP_LOGI(TAG,"\nsystem_get_free_heap_size after accept  =%d\n\n\n",system_get_free_heap_size());				
					
					
					
					ESP_LOGI(TAG,"\nsystem_get_free_heap_size befor close  newconn =%d\n\n\n",system_get_free_heap_size());
				
					 newconn->recv_timeout=2000;
					
					
					
					xTaskCreate(http_server_netconn_serve,"http_server_netconn_serve",5000,newconn,10,http_server_netconn_serve_Task);
					
						
					
				}			
				
				
			} while(err_accept == ERR_OK);
			
			
		   netconn_close(conn);
		   ESP_LOGI(TAG,"conn is close");
		   netconn_delete(conn); 
	  } /*err_listen end */
    
    }/*conn end */
	
	vTaskDelete(NULL);
     
   ESP_LOGI(TAG,"http exit");
}

void http_server_netconn_serve(void *pvParameters)
{
	
	  struct netbuf *inbuf;
	  char *buf;
	  
	  u16_t buflen;
	  err_t err;
		
		
	  /* Read the data from the port, blocking if nothing yet there.
	   We assume the request (the part we care about) is in one netbuf */
	   ESP_LOGI(TAG,"waitting for data");
	  err = netconn_recv(pvParameters, &inbuf);
	  
	


	  if (err == ERR_OK) 
	  {
		 
		err_t err1=netbuf_data(inbuf, (void**)&buf, &buflen);
		if (err1 != ERR_OK) 
		ESP_LOGI(TAG,"Data recived from client is not copied to buffer"); 
		
		ESP_LOGI(TAG,"\nbuflen=%d\n",buflen);
			  
	    ESP_LOGI(TAG,"system_get_free_heap_size befor paser function call=%d",system_get_free_heap_size());
	    parser(buf,buflen,pvParameters);
		ESP_LOGI(TAG,"system_get_free_heap_size after paser function call=%d",system_get_free_heap_size());
			  
			  
		netbuf_delete(inbuf);
			
		err=netconn_close(pvParameters);
		if (err != ERR_OK) 
		ESP_LOGI(TAG,"pvParameters not closed succesfully in parser");
		
		err_t err_newconn_d=netconn_delete(pvParameters); 
		if (err_newconn_d != ERR_OK) 
		ESP_LOGI(TAG,"newconn not delete succesfully");
			
		ESP_LOGI(TAG,"system_get_free_heap_size after delete and befor free =%d",system_get_free_heap_size());
			
		//~ netconn_free(pvParameters);
		//~ ESP_LOGI(TAG,"system_get_free_heap_size after calling netconn_free =%d",system_get_free_heap_size());
		
		 

	  }
	  
	  
	
	
	
	
	task_delete=1;
	
	ESP_LOGI(TAG,"http_server_netconn_serve Task deleted");
  
}

I also use spiffs my spiifs partition is as following:

Code: Select all

## Label            Usage          Type ST Offset   Length
0 nvs              WiFi data        01 02 00009000 00006000
1 phy_init         RF data          01 01 0000f000 00001000
2 factory          factory app      00 00 00010000 00100000
3 storage          Unknown data     01 82 00110000 00200000
when my board stop used spiffs is 19076 bytes.
My free heap size is 200000



here parser() function handles my buffer.
I am using idf v2.0 and modified app_lib.c.(no more require to call netconnfree() externally)
Is there anything i miss?

Dig Kleppe
Posts: 26
Joined: Wed Jun 28, 2017 5:03 pm

Re: wifi: bcn_timout,ap_probe_send_start

Postby Dig Kleppe » Fri Dec 08, 2017 5:51 pm

I have never heard of app_lib (the same for spiff i'm afraid) So i cannot help you.
You can always try the bare LWIP server from the zip, runs fine now.
Dig

pratik.yadav.455
Posts: 23
Joined: Thu Oct 26, 2017 7:34 am

Re: wifi: bcn_timout,ap_probe_send_start

Postby pratik.yadav.455 » Sat Dec 09, 2017 8:50 am

Dig Kleppe wrote:I have never heard of app_lib (the same for spiff i'm afraid) So i cannot help you.
You can always try the bare LWIP server from the zip, runs fine now.
Dig

ok thanks

Raimundo
Posts: 2
Joined: Thu Dec 28, 2017 5:31 pm

Re: wifi: bcn_timout,ap_probe_send_start

Postby Raimundo » Mon Jan 15, 2018 2:39 am

Hello!

Trying run PROTOCOLL->HTTP_REQUEST example, I'm getting the error below:
Has anyone ever experienced this???
Thanks a lot for some help!


Guru Meditation Error: Core 0 panic'ed (IllegalInstruction)
. Exception was unhandled.
Register dump:
PC : 0x4010c227 PS : 0x00060c30 A0 : 0x00000000 A1 : 0x3ffe5260
0x4010c227: http_get_task at /home/raimundo/esp/esp-idf/gatt_client/main/./gattc_demo_.c:242

A2 : 0xffffffff A3 : 0x00000000 A4 : 0x00001000 A5 : 0x00000080
A6 : 0x3ffd2aed A7 : 0x00000000 A8 : 0x8010c222 A9 : 0x3ffe5210
A10 : 0x40115e8c A11 : 0x3ffc5f8c A12 : 0x3f40ada0 A13 : 0x0000001f
0x40115e8c: vprintf at /Users/ivan/e/newlib_xtensa-2.2.0-bin/newlib_xtensa-2.2.0/xtensa-esp32-elf/newlib/libc/stdio/../../../.././newlib/libc/stdio/vprintf.c:35

A14 : 0x00000001 A15 : 0x00000005 SAR : 0x00000004 EXCCAUSE: 0x00000000
EXCVADDR: 0x00000000 LBEG : 0x400014fd LEND : 0x4000150d LCOUNT : 0xfffffffc

Backtrace: 0x4010c227:0x3ffe5260 0x7ffffffd:0x3ffe5300
0x4010c227: http_get_task at /home/raimundo/esp/esp-idf/gatt_client/main/./gattc_demo_.c:242


Rebooting...
ets Jun 8 2016 00:22:57

Who is online

Users browsing this forum: No registered users and 95 guests