Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 03:15 27 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Any TCP gurus out there?

Author Message
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9119
Posted: 04:44pm 11 Dec 2023
Copy link to clipboard 
Print this post

I've just posted this on the Pico forum but thought someone here may also be able to help

When a browser connects to the Pico-W action as a TCP-Server on port 80 it requests a connection and once accepted sends a request as per the debug dump below. My code then satisfies that request and closes the PCB - all that works well. However, if preload is enabled on the browser - default on Chrome and Edge a second connection is requested which is accepted but no data is received by the Pico-W and the connection just stays open consuming resource - see the second code segment. I've implemented a timer to kill off runt connections and you can see my close acting in the code segment. However, despite getting a success return the polling continues until some seconds later I see the third code segment.
Can anyone tell me what the TCP server should do when it sees the second connection but no request. Am I handling it correctly by pre-emptively closing it? Why is my close not stopping the connection immediately instead leaving LWIP to tidy up. If I don't close the second connection then my limited number of PCBs is exhausted and that will stop the program.
Any help appreciated.
Like DarkElvenAngel I'm seeing the program crashing after running for some time - often 12 hours or more and am trying to get to the bottom of the issue and these runt connections may not be the issue but are certainly untidy.



TCP connection request 55910 -> 80.
TCP connection established 55910 -> 80.
HTTP Client connected 2003be80 on pcb 0
Connection still free 7
Tcp_HTTP_recv on pcb 0 / 441
tcp_recved: received 441 bytes, wnd 11680 (0).
Stack pointer is 20041d58 free space on heap 10224
TCP connection request 55911 -> 80.
TCP connection established 55911 -> 80.
HTTP Client connected 2003bd38 on pcb 1
Connection still free 6
sending page header to pcb 0
sending page to pcb 0
sending page to pcb 0
sending page to pcb 0
sending page to pcb 0
sending page end to pcb 0
tcp_server_sent 2920
tcp_server_sent 2920
tcp_server_sent 958
tcp_close: closing in State: CLOSE_WAIT
Close success 2003be80 on pcb 0



tcp_slowtmr: processing active pcb
tcp_slowtmr: polling application
tcp_slowtmr: processing active pcb
tcp_slowtmr: polling application
tcp_slowtmr: processing active pcb
tcp_slowtmr: polling application
tcp_slowtmr: processing active pcb
tcp_slowtmr: polling application
tcp_slowtmr: processing active pcb
tcp_slowtmr: polling application
tcp_slowtmr: processing active pcb
tcp_slowtmr: polling application
tcp_slowtmr: processing active pcb
tcp_slowtmr: polling application
tcp_slowtmr: processing active pcb
tcp_slowtmr: polling application
tcp_slowtmr: processing active pcb
tcp_slowtmr: polling application
Warning PCB 1 still open
tcp_close: closing in State: ESTABLISHED
Close success 2003baa8 on pcb 1
tcp_slowtmr: processing active pcb
tcp_slowtmr: polling application
tcp_slowtmr: processing active pcb



tcp_slowtmr: processing active pcb
tcp_slowtmr: polling application
tcp_slowtmr: processing active pcb
tcp_slowtmr: removing pcb stuck in FIN-WAIT-2
tcp_pcb_purge
 
led-bloon

Senior Member

Joined: 21/12/2014
Location: Australia
Posts: 205
Posted: 07:32pm 11 Dec 2023
Copy link to clipboard 
Print this post

No guru but...
You have access to the originating IP that makes the connection request.
After a connection, reject (ignore) any further connection requests from
the same IP until the original connection is closed?
(I am sure the originating IP is constant)
led
Miss you George
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9119
Posted: 07:37pm 11 Dec 2023
Copy link to clipboard 
Print this post

Unfortunately, that doesn't work. It is perfectly reasonable for them to make multiple requests for pictures, css etc. The issue here is that it request the connection and then does nothing on it
 
LeoNicolas

Guru

Joined: 07/10/2020
Location: Canada
Posts: 479
Posted: 08:31pm 11 Dec 2023
Copy link to clipboard 
Print this post

Just for curiosity, have you test it with Firefox or any other browser that is not from the WebKit family?
 
homa

Guru

Joined: 05/11/2021
Location: Germany
Posts: 351
Posted: 08:49pm 11 Dec 2023
Copy link to clipboard 
Print this post

What kind of header does the second connection have?

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9119
Posted: 10:44pm 11 Dec 2023
Copy link to clipboard 
Print this post

It doesn't ever send anything, it just makes a connection request
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6098
Posted: 04:26am 12 Dec 2023
Copy link to clipboard 
Print this post

Definitely not a guru of any kind.

I doubt if closing the inactive connection will cause any problems with the browser.

My "production" system is running 7.07.08RC5 and seems to be rock steady.

My test system running 5.08.00b4 falls over without any connections being initiated via the network. It runs happily for a few hours or more before  reboot and no heartbeat LED flashing although the USB console works.

I am in the process of adding more debug code but I doubt if the extra TCPIP connection is causing the problems.

Jim
VK7JH
MMedit   MMBasic Help
 
TheMonkeys

Regular Member

Joined: 15/12/2022
Location: Australia
Posts: 59
Posted: 05:27am 16 Dec 2023
Copy link to clipboard 
Print this post

I'm unsure if this will help, but I thought I'd share.

I have observed that after a period of inactivity - around 3-5 minutes - the WebMite frequently takes approximately 7 seconds to respond to a browser request. This behaviour has been consistent for quite a while.

This is regardless of the type of request (transmit page or file).

I should add that I use javascript XMLHttpRequest() for many page requests, but it seems not to make a difference.

Cheers,

Chris.
 
TheMonkeys

Regular Member

Joined: 15/12/2022
Location: Australia
Posts: 59
Posted: 06:32am 16 Dec 2023
Copy link to clipboard 
Print this post

Oh, yes.

From my 404 log...
26-09-2023 01:29:07 2
GET / HTTP/1.1
Host: xxx.xxx.xxx.xxx:2040
User-Agent: Mozilla/5.0 (compatible; InternetMeasurement/1.0; +https://internet-measurement.com/)
Connection: close
Accept: */*
Accept-Encoding: gzip

26-09-2023 02:00:02 0
Host: 192.168.0.102:2040
Connection: close


This - as you can see from the dates - is a while ago.

The second entry - a request from a PHP script on my logging server - is missing:
GET /ldata.piml HTTP/1.1

from the start, which still happens every now & then. I've written a handler for it, but perhaps the WebMite is occasionally missing the first part of the request?

Hope this helps,

Chris.
Edited 2023-12-16 16:33 by TheMonkeys
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024