How to get large data from web page?

Hi, could someone tell me how to get large data from web page?
I’m using Netconn interface + lwip + FreeRTOS on stm32f407vg.

I tried to use a “taskENTER_CRITICAL();” and “taskEXIT_CRITICAL();” for stopping an “osKernelStart” during getting a large data …
But, it did not help!

Browser writes:
The connection was reset
During page download, the connection to the server was reset.
But ping works!

What am I doing wrong?

Below a code for obtaining data

...
if ((strncmp(buf, "POST /STM32F4xx.html", 20) == 0)
						|| (strncmp(buf, "POST / ", 7) == 0)) {
					/* Load STM32F4xx page */
					parse(buf); // 
					fs_open(&file, "/STM32F4xx.html");
					taskENTER_CRITICAL();
					printf("- taskENTER_CRITICAL - \n\r");
					netconn_write(conn, (const unsigned char* )(file.data),
							(size_t )file.len, NETCONN_NOCOPY);
					printf("- taskEXIT_CRITICAL - \n\r");
					taskEXIT_CRITICAL(); 
					fs_close(&file);
				} else { ...

taskENTER/EXIT_CRITICAL disable/enable (FrreRTOS covered) interrupts.
I doubt that netconn_write and likely also printf work with interrupts disabled.
Also critical sections are intended for a VERY SHORT period of time/code sequence to avoid disabling interrupts for a longer time for obvious reasons.
If you think that netconn_write isn’t working as expected I’d recommend to check the return values of functions called :wink:
Network traffic can be checked with Wireshark at least, maybe curl can be handy for http traffic testing.

Thank you for answer I don’t think that netconn_write isn’t working as extected this is the first thing that came to my mind, if I transfer a large amount of data from the web page …
Do you think I do not need to use the "taskENTER/EXIT_CRITICAL " and “NETCONN” itself can to process a large amount of data?

And second question about “Wireshak”:
Thanks for adviсe to use “Wireshak”!
You wrote to me need to check the return values of functions called…
I found out how to check that data the web page sends, see screen.
But, i don’t know how to check the return values of functions called in"Wireshak".
Could you help my find out in “Wireshak” how do I need to check the return values of called functions?

You shouldn’t use critical sections for long lasting operations like transferring large amounts of data over network. Never ! And how should a critical section help there in any way ?
You should also check the lwIP API documentation of netconn_write regarding it’s return values (ok / error codes) and it’s behavior and potential limitations.
That’s what I meant with return values. The return values of the functions called in your code e.g. netconn_write, fs_open etc.
How do you know if the functions called were successful ?
However - it’s good and pretty useful using Wireshark to verify the data you intended to send back to the browser and the overall http protocol flow.

1 Like

“Get” request I can send about 30 times and after stm32 freezes up. The quantity of “Get” requests depends from “heap_size”!
And if send “POST” request stm32 freezes up at once!
Any ideas?

Well, if the 1st problem depends on heap size there might be memory leak. Or sth. else.

And if send “POST” request stm32 freezes up at once!

That’s the easy one :slight_smile: Just use your debugger and follow the code … as we all do it.
Good luck :+1: