axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Ewins <>
Subject Re: Socket problems
Date Wed, 31 Jul 2002 15:13:57 GMT wrote:
>>The socket-based code is never going to perform particularly well 
>>because it sets up and tears down the http connections each time. 
> I tried to send two request on the same socket towards Tomcat, but I
> always failed. It seemed that Tomcat always closed the connection after
> the first request served. Of course it may happed that it's just a matter
> of configuration, but I never succeded doing it. 

trying to send two on the same /socket/ is never going to work unless 
you're using http 1.1 on both sides, and the client code supports it. 
Like I said, the CommonsHTTPSender is the only sender that it is even 
possible to do this with, but the client's client-side http session is 
not being kept around for reuse in axis (hey, the code is only 2 weeks 
old!! :) ). So, not this week.

> I also tried setting TcpNoDelay and SoLinger on the sockets, but
> that doesn't helped either. :(
hmm. Can't comment on this much. TcpNoDelay won't help you anyway (it 
affects the ramping of transmission speed at the start of a connection, 
aka the 'Nagle' algorithm). SoLinger support has always been written off 
as being unreliable, but last time I looked at it was ages ago, TCP 
stacks have probably improved. However, it isnt really the kind of low 
level agony I want to be involved with...

> I also failed on caching URLConnections. I always get an IllegalStateException
> when reusing the connection.

this is understandable, at least. What happened was that you set the 
headers on a connection that was already open. Again, you need a full 
Http 1.1 implementation to fix this, and only the commons HttpClient is 
going to do this - the HttpSender is a long, long way off from being there.

The 'correct' way to get a sequence of transactions over a single socket 
connection is to use the commons HttpClient class, instead of accessing 
the HttpConnection directly. You'd need to store the HttpClient object 
in the axis MessageContext. The HttpClient 'knows' how to reuse a 
socket[1], and by setting the right HTTP options it will ensure the 
webserver reuses a socket too. Its not a quick fix to enable this. To me 
it looks like all of the code currently written in terms of 
'HttpConnection' should be written to return 'HttpClient's instead.

> I looks like this day is a day of failures for me. :)
> Anyway, thank for the tips, I appreciate them. -Geza

No probs, I am learning by looking at this too :)


[1] actually its HttpMethodBase that does this, but unless you keep 
giving it back the same HttpConnection thats stored in the HttpClient 
the reuse doesnt take place.

View raw message