Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: Add Configurable Timeout to Socket Connection Methods #153

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mz1999
Copy link

@mz1999 mz1999 commented Jul 15, 2023

The ORB does not set a timeout when establishing a connection, and in some cases, such as when the opposite endpoint has set up firewall rules or is connecting to a non-existent IP address, the connection process will block for a long time at the native method:

"http-listener-1(3)" #42 daemon prio=5 os_prio=31 cpu=10.88ms elapsed=436.72s tid=0x00007f8218374800 nid=0xec03 runnable  [0x0000700004bd7000]
   java.lang.Thread.State: RUNNABLE
    at sun.nio.ch.Net.connect0(java.base@17.0.7/Native Method)
    at sun.nio.ch.Net.connect(java.base@17.0.7/Net.java:579)
    at sun.nio.ch.Net.connect(java.base@17.0.7/Net.java:586)
    at sun.nio.ch.SocketChannelImpl.connect(java.base@17.0.7/SocketChannelImpl.java:853)
    at com.sun.corba.ee.impl.misc.ORBUtility.openSocketChannel(ORBUtility.java:92)
    at org.glassfish.enterprise.iiop.impl.IIOPSSLSocketFactory.createSocket(IIOPSSLSocketFactory.java:306)
    at com.sun.corba.ee.impl.transport.ConnectionImpl.<init>(ConnectionImpl.java:229)
    at com.sun.corba.ee.impl.transport.ConnectionImpl.<init>(ConnectionImpl.java:254)
    at com.sun.corba.ee.impl.transport.ContactInfoImpl.createConnection(ContactInfoImpl.java:108)
    at com.sun.corba.ee.impl.protocol.ClientRequestDispatcherImpl.beginRequest(ClientRequestDispatcherImpl.java:200)
    ...

By using tcpdump to capture packets, it was discovered that the kernel was constantly performing TCP retransmissions, with the number of retransmissions being controlled by the kernel parameter net.ipv4.tcp_syn_retries and using an exponential backoff strategy. On my machine, it takes 130 seconds for the timeout to occur.

tcp retransmissions

Therefore a configurable timeout should be set for the connection process. In fact, ORB already has a configurable property com.sun.corba.ee.transport.ORBTCPConnectTimeouts, but the connection process does not currently utilize this parameter.

This PR introduces a significant enhancement to the socket connection methods, providing more flexibility and control over socket connections.Additionally I add unit tests to ensure the correct functionality of the updated methods. These tests cover both normal operation and timeout scenarios.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant