Re: [I] [BUG] TCP keep alive sockets not working [nuttx]

2025-05-28 Thread via GitHub


acassis closed issue #16447: [BUG] TCP keep alive sockets not working
URL: https://github.com/apache/nuttx/issues/16447


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [I] [BUG] TCP keep alive sockets not working [nuttx]

2025-05-27 Thread via GitHub


linguini1 commented on issue #16447:
URL: https://github.com/apache/nuttx/issues/16447#issuecomment-2914840431

   > You can submit the PR directly. Thank you very much.
   
   Thank you!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [I] [BUG] TCP keep alive sockets not working [nuttx]

2025-05-27 Thread via GitHub


zhhyu7 commented on issue #16447:
URL: https://github.com/apache/nuttx/issues/16447#issuecomment-2914823618

   > > [@linguini1](https://github.com/linguini1) could you test the following 
patch?
   > > ```
   > > tcp_timer:
   > >   /* Yes.. Has the retry count expired? */
   > > 
   > >   if (conn->keepretries >= conn->keepcnt)
   > > {
   > >   /* Yes... stop the network monitor, closing the
   > >* connection and all sockets associated with the
   > >* connection.
   > >*/
   > > 
   > > + devif_conn_event(conn->dev, TCP_ABORT, 
conn->sconn.list);
   > >   tcp_stop_monitor(conn, TCP_ABORT);
   > > }
   > > ```
   > 
   > Thank you [@zhhyu7](https://github.com/zhhyu7), this resolved the issue! I 
am very appreciative of your help. Would you be able to either submit the patch 
as a PR or would you like me to submit this patch?
   
   @linguini1 You can submit the PR directly. Thank you very much.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [I] [BUG] TCP keep alive sockets not working [nuttx]

2025-05-27 Thread via GitHub


linguini1 commented on issue #16447:
URL: https://github.com/apache/nuttx/issues/16447#issuecomment-2913398083

   > [@linguini1](https://github.com/linguini1) could you test the following 
patch?
   > 
   > ```
   > tcp_timer:
   >   /* Yes.. Has the retry count expired? */
   > 
   >   if (conn->keepretries >= conn->keepcnt)
   > {
   >   /* Yes... stop the network monitor, closing the
   >* connection and all sockets associated with the
   >* connection.
   >*/
   > 
   > + devif_conn_event(conn->dev, TCP_ABORT, 
conn->sconn.list);
   >   tcp_stop_monitor(conn, TCP_ABORT);
   > }
   > ```
   
   Thank you @zhhyu7, this resolved the issue! I am very appreciative of your 
help. Would you be able to either submit the patch as a PR or would you like me 
to submit this patch? 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [I] [BUG] TCP keep alive sockets not working [nuttx]

2025-05-27 Thread via GitHub


zhhyu7 commented on issue #16447:
URL: https://github.com/apache/nuttx/issues/16447#issuecomment-2911596744

   @linguini1 could you test the following patch?
   ```
   void tcp_stop_monitor(FAR struct tcp_conn_s *conn, uint16_t flags)
   {
 DEBUGASSERT(conn != NULL && conn->dev != NULL);
   
 /* Notify all registered callbacks */
   
 devif_conn_event(conn->dev, flags, conn->sconn.list);
   
 /* Stop the network monitor */
   
 tcp_shutdown_monitor(conn, flags);
   }
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [I] [BUG] TCP keep alive sockets not working [nuttx]

2025-05-26 Thread via GitHub


EliasJRH commented on issue #16447:
URL: https://github.com/apache/nuttx/issues/16447#issuecomment-2910860582

   (Sorry for excessive mentions) @wengzhe you were mentioned on a what seems 
to be a similar issue [here](github.com/apache/nuttx/issues/13493). Do you have 
any advice?
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [I] [BUG] TCP keep alive sockets not working [nuttx]

2025-05-26 Thread via GitHub


bskdany commented on issue #16447:
URL: https://github.com/apache/nuttx/issues/16447#issuecomment-2910651049

   @zhhyu7 I saw you removed the tcp_callback when accepting conn timeout, do 
you happen to know if that change might have interfered with TCP Keepalive?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [I] [BUG] TCP keep alive sockets not working [nuttx]

2025-05-26 Thread via GitHub


linguini1 commented on issue #16447:
URL: https://github.com/apache/nuttx/issues/16447#issuecomment-2910641686

   @wangyingdong I saw you wrote the zero-probe timer support and 
`tcp_xmit_probe()`. Do you have any advice which may help with this issue?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [I] [BUG] TCP keep alive sockets not working [nuttx]

2025-05-26 Thread via GitHub


linguini1 commented on issue #16447:
URL: https://github.com/apache/nuttx/issues/16447#issuecomment-2910621768

   @a-lunev Do you have any ideas what this issue might be? I saw you've made 
some changes a long time ago to the networking logic, and thought you might now 
better than me.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [I] [BUG] TCP keep alive sockets not working [nuttx]

2025-05-26 Thread via GitHub


linguini1 commented on issue #16447:
URL: https://github.com/apache/nuttx/issues/16447#issuecomment-2910564953

   Noticed that after the probes receive no reply, the TCP stack calls the 
abort mechanism indefinitely:
   
   ```console
   [CPU0] [ 2] tcp_timer: aborted
   [CPU0] [ 2] tcp_timer: aborting
   [CPU0] [ 2] tcp_timer: aborted
   [CPU0] [ 2] tcp_timer: aborting
   [CPU0] [ 2] tcp_timer: aborted
   [CPU0] [ 2] tcp_timer: aborting
   [CPU0] [ 2] tcp_timer: aborted
   [CPU0] [ 2] tcp_timer: aborting
   [CPU0] [ 2] tcp_timer: aborted
   [CPU0] [ 2] tcp_timer: aborting
   [CPU0] [ 2] tcp_timer: aborted
   [CPU0] [ 2] tcp_timer: aborting
   [CPU0] [ 2] tcp_timer: aborted
   [CPU0] [ 2] tcp_timer: aborting
   ```
   
   This is net/tcp/tcp_timer.c:704


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



[I] [BUG] TCP keep alive sockets not working [nuttx]

2025-05-26 Thread via GitHub


linguini1 opened a new issue, #16447:
URL: https://github.com/apache/nuttx/issues/16447

   ### Description / Steps to reproduce the issue
   
   I am having some issues with TCP keep-alive on the W5500-EVB pico. Namely, 
all the keep-alive socket options can be set nominally (no error from 
`setsockopt`), but the connection does not reset after the keep-alive time. I 
am testing this by setting up a connection successfully between two W5500-EVB 
Picos, and then turning off the client EVB Pico and waiting for the timeout to 
occur. The timeout never happens (blocking `recv` should return ECONNRESET as 
it does on Linux, or at least some error code).
   
   For testing, I am using 2 probes with an interval of 5 seconds.
   
   This is the code I am using to setup the TCP socket:
   
   ```c
   static int controller_init(controller_t *controller, uint16_t port) {
   int err;
   
   /* Initialize the socket connection. */
   controller->sock = socket(AF_INET, SOCK_STREAM, 0);
   if (controller->sock < 0) return errno;
   
   int opt = 1;
   err = setsockopt(controller->sock, SOL_SOCKET, SO_REUSEADDR, &opt, 
sizeof(opt));
   if (err < 0) {
   herr("Failed to set option SO_REUSEADDR: %d\n", errno);
   return errno;
   }
   
   /* Create address */
   controller->addr.sin_family = AF_INET;
   controller->addr.sin_addr.s_addr = INADDR_ANY;
   controller->addr.sin_port = htons(port);
   
   /* Make sure client socket fd is marked as invalid until it gets a 
connection */
   controller->client = -1;
   
   if (bind(controller->sock, (struct sockaddr *)&controller->addr, 
sizeof(controller->addr)) < 0) {
   herr("Failed to bind\n");
   return errno;
   }
   
   /* Set up keep-alive options */
   
   int keepalive = 1;
   err = setsockopt(controller->sock, SOL_SOCKET, SO_KEEPALIVE, (void 
*)&keepalive, sizeof(keepalive));
   if (err < 0) {
   herr("Failed to set socket as keep-alive: %d.\n", errno);
   return errno;
   }
   
   /* Each interval between ACK probes is `int_secs` long */
   
   int int_secs = KEEPALIVE_INTERVAL_SECS;
   err = setsockopt(controller->sock, IPPROTO_TCP, TCP_KEEPINTVL, 
&int_secs, sizeof(int));
   if (err < 0) {
   herr("Failed to set keep-alive interval to %d: %d.\n", int_secs, 
errno);
   return errno;
   }
   
   hinfo("Set keep-alive interval %d s\n", int_secs);
   
   int count = KEEPALIVE_N_PROBES; /* Gives 10 probes (10 * `int_secs` 
seconds) to regain connection */
   err = setsockopt(controller->sock, IPPROTO_TCP, TCP_KEEPCNT, &count, 
sizeof(int));
   if (err < 0) {
   herr("Failed to set keep-alive probe count to %d: %d.\n", count, 
errno);
   return errno;
   }
   
   hinfo("Set number of keep-alive probes: %d\n", count);
   
   return 0;
   }
   ```
   
   And here is the code where I expect to see the timeout:
   
   ```c
   // controller->client is the `accept`-ed client connection fd
   bread = recv(controller->client, (char *)&hdr + total_read, sizeof(hdr) - 
total_read, 0);
   if (bread == -1) {
   herr("Error reading message header: %s\n", strerror(errno));
   
   if (errno == ECONNRESET) {
   // TODO: this should trigger an abort because it happens when TCP 
keep-alive is done
   herr("Lost connection! ABORT!\n");
   }
   
   break;
   } else if (bread == 0) {
   herr("Control box disconnected.\n");
   break;
   }
   total_read += bread;
   ```
   
   I have also used Wireshark to listen to the network traffic being sent and I 
am unable to see any of the probes being sent at all.
   
   ### On which OS does this issue occur?
   
   [OS: Linux]
   
   ### What is the version of your OS?
   
   Linux 6.14.7-arch2-1 SMP PREEMPT_DYNAMIC Thu, 22 May 2025 05:37:49 + 
x86_64 GNU/Linux
   
   ### NuttX Version
   
   master
   
   ### Issue Architecture
   
   [Arch: arm]
   
   ### Issue Area
   
   [Area: Networking]
   
   ### Host information
   
   _No response_
   
   ### Verification
   
   - [x] I have verified before submitting the report.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]