You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Wayne Johnson (JIRA)" <ji...@apache.org> on 2010/05/03 18:52:56 UTC

[jira] Commented: (NET-24) [net] Commons RLogin timeout

    [ https://issues.apache.org/jira/browse/NET-24?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12863404#action_12863404 ] 

Wayne Johnson commented on NET-24:
----------------------------------

I ran into the same issue and implemented the bypass listed in NET-141.  

1) RCommandClient will automatically retry a connect on another port pair on a ConnectException in the socket.connect. To get around this I added a catch to Christian's code to catch a ConnectException and rethrow it as a IOException.  Here's a code snippet for my modification:

	        socket.bind(localaddr);
	        try
	        {
	            socket.connect(remoteaddr, connectionTimeout);
	        }
	        /* RCommandClient intercepts SocketExceptions and blindly retries on 
	         * another socket pair.  A ConnectException is more permanent that just
	         * having a busy socket pair and we rethrow it as an IOException to get
	         * by the intercept. 
	         */
	        catch (ConnectException e)
	        {
	            throw new IOException(e);
	        }

2) There is a typo in Christian's code in the method when using InetAddress to createSocket(). The code should be

       public Socket createSocket(InetAddress address, int port, InetAddress localAddress, int localPort) throws IOException
{ return createSocket(address.getHostName(), port, localAddress, localPort); }

Note that the original code passed 0 for the localPort when the user had specified a localPort.



> [net] Commons RLogin timeout
> ----------------------------
>
>                 Key: NET-24
>                 URL: https://issues.apache.org/jira/browse/NET-24
>             Project: Commons Net
>          Issue Type: Bug
>    Affects Versions: 1.2
>         Environment: Operating System: All
> Platform: PC
>            Reporter: Matt Parker
>             Fix For: 2.0
>
>
> When calling the connect method on org.apache.commons.net.bsd.RLoginClient,
> timeout can take 10 minutes +.
> I have found that this is down to the RCommandClient connect method.
> The exception to catch should be a BindException.  The logic here is that so
> long as we have got a valid local port and address (no BindException) then we
> shouldn't bother trying all of the other local ports.  If this is adopted, then
> a connect exception is thrown from the connect method indicating that the remote
> server is not present or responding.
> Please see snippet from the corrected connect method below.
>         for (localPort = MAX_CLIENT_PORT; localPort >= MIN_CLIENT_PORT; --localPort)
>         {
>             try
>             {
>                 _socket_ =
>                     _socketFactory_.createSocket(host, port, localAddr, localPort);
>             }
> //            catch (SocketException e)
>             catch (BindException e)
>             {
>                 continue;
>             }
>             break;
>         }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.