Bug 66476 - org.apache.tomcat.util.net.Acceptor.run Socket accept failed java.io.IOException: Duplicate accept detected.
Summary: org.apache.tomcat.util.net.Acceptor.run Socket accept failed java.io....
Status: RESOLVED DUPLICATE of bug 65776
Alias: None
Product: Tomcat 9
Classification: Unclassified
Component: Connectors (show other bugs)
Version: 9.0.58
Hardware: PC Linux
: P2 critical (vote)
Target Milestone: -----
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-02-13 14:05 UTC by Omkar
Modified: 2023-02-15 09:50 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Omkar 2023-02-13 14:05:52 UTC
Hello, 

Sometimes we see below error in our tomcat log file, and when this happens tomcat stops accepting any more requests : -

----------------------------------
ERROR: -
----------------------------------
10-Feb-2023 02:16:19.618 SEVERE [http-nio-80-Acceptor] org.apache.tomcat.util.net.Acceptor.run Socket accept failed
        java.io.IOException: Duplicate accept detected. This is a known OS bug. Please consider reporting that you are affected: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1924298
                at org.apache.tomcat.util.net.NioEndpoint.serverSocketAccept(NioEndpoint.java:548)
                at org.apache.tomcat.util.net.NioEndpoint.serverSocketAccept(NioEndpoint.java:78)
                at org.apache.tomcat.util.net.Acceptor.run(Acceptor.java:129)
                at java.lang.Thread.run(Thread.java:748)

----------------------------------


Apache Tomcat version : - Apache Tomcat/9.0.58
Frequency of occurance : - Sometimes
Reproducible consistently ? : - No, it appears sometimes ....randomly...and on tomcat restart it goes away but it may appear randomly sometime later
OS = CentOS
Kernel (uname -sr) = Linux 6.0.9-1.el7.elrepo.x86_64
Server arch = amd64

Setup: - 
We are using Camunda 7.16 BPMN tool which comes with inbuilt Apache Tomcat 9.0.58. This is deployed on our Linux VM (CentOS). The VM is within our company network, and ... via company's firewall another trusted application on Azure cloud (outside company network)...is only allowed to make REST API calls to Camunda (hosted on Tomcat). When Tomcat is started all works fine, requests placed from trusted application on Azure Cloud are able to reach our Tomcat and our application works on it, until out of the blue and randomly above error occurs and tomcat no longer serves request coming from external application on cloud. 
On the other hand, if we fire similar request from within our company network machines as many times as we want... as frequently as possible, in such scenario, the above error does not occur and Tomcat allows all requests.
In other words, it seems above issue occurs only for external requests and not internal ones. 

What has been tried so far ?: -
From several posts after google search it was found that Linux Kernel version could help. Previously it was 3.x and now it is upgraded to 6.0.9-1 and Apache Tomcat version is 9.0.58... still we face the above error.

Queries: -
1) Why it behaves strangely with external requests and not with internal ones ?
2) How can we consistently reproduce the issue ?
3) What could be the possible cause and how to fix it ?

Any help in this regard can be very helpful.

Let me know if you need any more information.

Thanks and Regards
Omkar Patkar
Comment 1 Mark Thomas 2023-02-14 19:27:34 UTC
I suspect this is triggered by local port re-use. Possible scenarios for that are described in bug 65776.

I suspect what you really need is an update to Tomcat 9.0.59 or later.

It might be possible to reduce the frequency via configuration (e.g. disable HTTP keep-alive) but those changes may cone with performance impacts.

The users list is the place to discuss possible workarounds if a Tomcat upgrade is not possible.

*** This bug has been marked as a duplicate of bug 65776 ***
Comment 2 Omkar 2023-02-15 03:31:32 UTC
(In reply to Mark Thomas from comment #1)
> I suspect this is triggered by local port re-use. Possible scenarios for
> that are described in bug 65776.
> 
> I suspect what you really need is an update to Tomcat 9.0.59 or later.
> 
> It might be possible to reduce the frequency via configuration (e.g. disable
> HTTP keep-alive) but those changes may cone with performance impacts.
> 
> The users list is the place to discuss possible workarounds if a Tomcat
> upgrade is not possible.
> 
> *** This bug has been marked as a duplicate of bug 65776 ***

Hi Thomas,

Thank you for prompt response. I really appreciate that. But I am still marking the status as "Unconfirmed" because, we have still not been able to find cause of the weird behavior. I mean, we can "assume" reuse of local port,... but why this happens "ONLY" for requests coming from outside network ? Why this does not happen for requests sent from within the internal company network. I mean, i would agree if the behaviour is same across different requests, but here the distinction is clear. 
The issue occurs "ONLY" for external requests and not internal requests. Why is it so ? What can we do to confirm that local port is re-used ONLY for external requests ? 
In other words, if i upgrade to Tomcat above 9.0.59 or above and if it still continues the wierd behavior for external requests then ? How can we be sure that upgrade is the only solution ? The bug 65776 you have referred definetly talks about similar issue, but it says nothing about external or internal requests.

We need your help to understand this unusual behavior. Let us know what more diagnostics we can perform to find the root cause. Together we can find the cause. One more information i would like to provide you here: -

The machine on which the Tomcat is running has local IP and public IP (for external network or world). When requests comes from within the company network it is via local IP and when the request comes from external world, it comes via public IP.

Thanks and Regards
Omkar Patkar
Comment 3 Mark Thomas 2023-02-15 09:50:54 UTC
The users list is the place to seek further help.

*** This bug has been marked as a duplicate of bug 65776 ***