-
Notifications
You must be signed in to change notification settings - Fork 24
Enhancement: Add Configurable Timeout to Socket Connection Methods #153
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
Conversation
Unfortunately this PR causes failure of two GlassFish test blocks. It is reproducible locally too. I tried to revert it and the security_all block passed. If someone can do a quick look on the diff, so we would avoid reverting it and patched the code instead, I would appreciate it.
|
Could you please provide more details on how to reproduce the test failures locally? I'm trying to investigate and resolve this issue. |
You can check out my branch in eclipse-ee4j/glassfish#25364 and then run
4 tests will fail. I already know what is wrong, but I am still not sure how to fix it. The cause is in somehow ambiguous java API, which allows to use same methods for blocking or nonblocking connect. Original code allowed both, so you did not see it and changed it to just blocking. However there are some methods using selectors which depend on nonblocking socket channel. And that is probably causing the issue you tried to fix. If we would not be able to fix it until Sunday, I will revert it and we can release 5.0.1 soon after that. GF8 is blocked by ORB for a long time now. Maybe we should refactor it somehow, so it would be cleaner and more reliable. It seems that
FYI, @pzygielo and @arjantijms |
defineSocket(useSelectThreadToWait, | ||
orb.getORBData().getSocketFactory().createSocket(socketType, new InetSocketAddress(hostname, port))); | ||
orb.getORBData().getSocketFactory().createSocket( | ||
orb.getORBData().connectionSocketType(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yet one question - why you replaced the socketType
parameter with orb.getORBData().connectionSocketType()
? It seems it did not change anything in test results, but ...
SocketChannel socketChannel = null; | ||
Socket socket = null; | ||
|
||
if (orb.getORBData().connectionSocketType().equals(ORBConstants.SOCKETCHANNEL)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aha, here it is too ... type was unused, and it took the value from the orbdata ... why?
9003
I'm a bit fuzzy on the details of this change since it was a while ago. If the issue is confirmed and the release is urgent, I'd recommend reverting it for now. I'll take some time next week to investigate the issue thoroughly. |
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:
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.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.