axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeff Elo (JIRA)" <axis-...@ws.apache.org>
Subject [jira] Commented: (AXIS-769) Socket Timeouts for Axis Clients
Date Tue, 08 Mar 2005 22:10:58 GMT
     [ http://issues.apache.org/jira/browse/AXIS-769?page=comments#action_60463 ]
     
Jeff Elo commented on AXIS-769:
-------------------------------

if anyone is interested, i've written a JDK 1.4 connection-timeout-capable socket factory
for axis 1.1:


public class TimeoutSocketFactory extends DefaultSocketFactory {
    private static int connectionTimeout = 5*1000;
    
    /**
     * @param attributes
     */
    public TimeoutSocketFactory(Hashtable attributes) {
        super(attributes);
    }
    
    /**
     * Creates a socket using jdk 1.4 timeouts
     *
     * @param host
     * @param port
     * @param otherHeaders
     * @param useFullURL
     *
     * @return Socket
     *
     * @throws Exception
     */
    public Socket create(
            String host, int port, StringBuffer otherHeaders, BooleanHolder useFullURL)
            throws Exception {

        TransportClientProperties tcp = TransportClientPropertiesFactory.create("http");

        Socket sock = null;
        boolean hostInNonProxyList = isHostInNonProxyList(host, tcp.getNonProxyHosts());

        if (tcp.getProxyUser().length() != 0) {
            StringBuffer tmpBuf = new StringBuffer();

            tmpBuf.append(tcp.getProxyUser())
                  .append(":")
                  .append(tcp.getProxyPassword());
            otherHeaders.append(HTTPConstants.HEADER_PROXY_AUTHORIZATION)
                        .append(": Basic ")
                        .append(Base64.encode(tmpBuf.toString().getBytes()))
                        .append("\r\n");
        }
        if (port == -1) {
            port = 80;
        }
        
        sock = new Socket();
        SocketAddress endpoint = null;
        if ((tcp.getProxyHost().length() == 0) ||
            (tcp.getProxyPort().length() == 0) ||
            hostInNonProxyList)
        {

            endpoint = new InetSocketAddress(host, port);

            if (log.isDebugEnabled()) {
                log.debug(Messages.getMessage("createdHTTP00"));
            }
        } else {
            endpoint = new InetSocketAddress(tcp.getProxyHost(),
                              new Integer(tcp.getProxyPort()).intValue());
            if (log.isDebugEnabled()) {
                log.debug(Messages.getMessage("createdHTTP01", tcp.getProxyHost(),
                          tcp.getProxyPort()));
            }
            useFullURL.value = true;
        }
        sock.connect(endpoint, connectionTimeout);        
        
        return sock;
    }
    
    
    public static int getConnectionTimeout() {
        return connectionTimeout;
    }
    public static void setConnectionTimeout(int timeout) {
        connectionTimeout = timeout;
    }
}

> Socket Timeouts for Axis Clients
> --------------------------------
>
>          Key: AXIS-769
>          URL: http://issues.apache.org/jira/browse/AXIS-769
>      Project: Axis
>         Type: Bug
>   Components: Basic Architecture
>     Versions: current (nightly)
>  Environment: Operating System: Other
> Platform: Other
>     Reporter: Davanum Srinivas
>     Assignee: Davanum Srinivas
>      Fix For: current (nightly)

>
> Note from "Jens Schumann" <jens@void.fm> on axis-dev@ mailing list.
> =====================================================
> Some broken load balancers in our network configuration caused hanging
> connections calling WebServices using Axis Clients (1.1RC2). Since the
> generated Axis Client Code does not set a default socket timeout the calling
> thread was blocking forever, something which wasn't as obvious as it could
> be. A default socket timeout would have been wonderful ;)
> With the current client code I am unable to set the socket timeout directly,
> so I need to alter the generated code to set a socket timeout for the
> underlying HttpSender. You may argue easy to fix, but there is another
> problem: The client code throws RemoteExceptions (and AxisFaults) only, so I
> am unable to treat local and remote failures differently. Analyzing Axis
> fault Strings isn't the best way to implement Exception handling.
> I am somewhat short on time and thus being said I hope someone else might be
> able to implement the following changes ;(.
> 1. Set default socket timeout for Axis Clients to 30 or 60 seconds.
> 2. Generate code which allows to set the socket timeout for the axis client
> easily.
> 3. Add a local exception (IOException?) to the exposed web service
> operations to allow better handling of local (socket) exceptions.
> I think 1 & 2 should be easy to fix, but 3 will break backwards
> compatibility.
> Jens
> =====================================================

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


Mime
View raw message