Re: intermittent connection callback exceptions

Peter Jones <[email protected]> Wed, 8 Oct 2008 02:19:22 -0400
Newsgroups gmane.comp.java.sun.rmi
Message-ID <20081008061922.GA1766@east>
On Wed, Oct 01, 2008 at 04:19:49PM -0700, Mark Ackerman wrote:
> Peter Jones wrote:

>>> Well they're not really in use, they just don't seem to be getting
>>> released fast enough. Not sure why.
>> 
>> In the typical life cycle of a JRMP connection, it is the client
>> side that initiates the closing of the connection (i.e. the client
>> side sends the first FIN), so it is on the client side that the
>> connection remains in the TIME_WAIT state for a period, typically
>> minutes, during which the same client address & port cannot be used
>> to connect to the same server address & port.  Perhaps the rate of
>> remote invocations to this endpoint is low enough that JRMP
>> connections are not getting reused (the default idle connection
>> timeout is 15 seconds), but high enough that they are accumulating
>> in the TIME_WAIT state-- exhausting the limited source ports for
>> the given destination address & port.
> 
> seems that setting ServerSocket.setReuseAddress(true) like Gregg
> suggested seems to help.

Do you mean Socket.setReuseAddress(true), instead of ServerSocket?
(For server sockets, at least Sun's JDK sets that option by default
anyway, and I wouldn't have expected it to help this case.)

For client sockets, I don't think that even that option would allow
the entire source/destination x address/port tuple to be reused while
there is still a connection in TIME_WAIT-- but it would allow the
initial bind to the local port to succeed even if there is a TIME_WAIT
connection with that same local port, so as long as the destination
addresses or ports are different, the connection can then succeed.  In
other words, without that option, the situation is even more
restrictive than I described above, but the option will help as long
as there are different destinations.

> I also diddled with setSoLinger().

I wouldn't expect that to help.

-- Peter

===========================================================================
To unsubscribe, send email to [email protected] and include in the body
of the message "signoff RMI-USERS".  For general help, send email to
[email protected] and include in the body of the message "help".

For a list of frequently asked RMI questions please refer to:
http://java.sun.com/j2se/1.3/docs/guide/rmi/faq.html

To view past RMI-USERS postings, please see:
http://archives.java.sun.com/archives/rmi-users.html