Re: intermittent connection callback exceptions

Mark Ackerman <[email protected]> Wed, 1 Oct 2008 16:19:49 -0700
Newsgroups gmane.comp.java.sun.rmi
Organization Resource Management Associates, Inc.
Message-ID <[email protected]>
Peter Jones wrote:
> On Tue, Sep 30, 2008 at 04:28:53PM -0700, Mark Ackerman wrote:
>   
>> that seems to be the problem, we have a custom socket factory that
>> you can limit the number of ports it can use (specified by an
>> optional config file).
>>     
>
> As this failure is happening on the client side of a remote invocation
> attempt (even though it is on the "server" in the larger application
> sense), I gather that this socket factory is limiting the source ports
> used on the client side of connections?  If so, why is that necessary?
>   
customer requirements. 
>   
>> Seems that all the ports are in use, (getting a
>> "java.net.BindException: Address already in use").
>>     
>
> And the socket factory's createSocket method is returning null in that
> case?  Seems like it should throw that BindException instead.
>
>   
yeah probably.  I never expected it to fail when it had a range of ports 
to choose from.  Changed
to throw the last BindException that's generated.
>> 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.
>
> -- Peter
>
>   
seems that setting ServerSocket.setReuseAddress(true) like Gregg 
suggested seems to help.
I was able to open numerous connections back to my PC, one right after 
another to the point I got
tired of trying.  Where-as before it was failing consistently at around 
7-8 connections.
I also diddled with setSoLinger().

===========================================================================
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