Hi Sean,

The current Restlet implementation creates a new HttpURLConnection instance
for each request. In order to allow connection reuse, the JDK apparently
requires us to reuse the exact same instance... I was expecting the JDK to
internally handle reuse, too bad! In order to enable reuse in our connector,
we would need to maintain a map of connection (hostUri -> HttpUrlConnection
instance + state). It's just a bit hard to know when a connection has been
fully used and can be put back in the pool, when to release it, etc.

I think a more promising way for high-demanding services like yours it to
provide a new connector based on Apache HTTP Client. I'll start looking into
adding that. 

Other thoughts?

Best regards,
Jerome  

> -----Message d'origine-----
> De : news [mailto:[EMAIL PROTECTED] De la part de Sean Landis
> Envoyé : samedi 11 novembre 2006 00:26
> À : [email protected]
> Objet : Re: Keeping a client connection open
> 
> Here's a followup...
> > Hi Sean,
> > 
> > I would have expected the other behavior as the JDK keeps 
> HTTP connections
> > alive by default.
> 
> This appears to be the case. I tried explicitly setting 
> http.keepAlive to
> true and http.maxConnections to say 50. Neither of these had 
> any effect
> on performance and, using ethereal, it is clear the connection 
> is closed and reopened between calls using the same client.
> 
> Here's a typical request header and body:
> 
> POST /persons/person HTTP/1.1
> 
> User-Agent: Noelios-Restlet-Engine/1.0b20
> 
> Accept: */*
> 
> Content-Type: text/plain
> 
> Cache-Control: no-cache
> 
> Pragma: no-cache
> 
> Host: wasatch.overstock.com:8080
> 
> Connection: keep-alive
> 
> Content-Length: 147
> 
> 
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> <PersonRequest xmlns="http://www.overstock.com/service1";>
>     <Id>20</Id>
> </PersonRequest>
> 
> And a corresponding response header and body:
> 
> HTTP/1.1 200 OK
> 
> Date: Fri, 10 Nov 2006 23:04:01 GMT
> 
> Server: Noelios-Restlet-Engine/1.0b20
> 
> Content-Type: text/plain;charset=ISO-8859-1
> 
> Content-Length: 250
> 
> 
> 
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> <PersonResponse xmlns="http://www.overstock.com/service1";>
>     <Id>20</Id>
>     <Name>Sean</Name>
>     <Phone>801-555-1212</Phone>
>     <Time>2006-11-10T16:04:01.500-07:00</Time>
> </PersonResponse>
> 
> > So, you may want to ensure that all your request entities 
> (representations)
> > have their "size" property precisely set.
> 
> The Content-Length values appear to be correct. 
> 
> > Also, feel free to have a look at
> > the implementation classes (just two) to see if our usage of
> > HttpURLConnection could be improved.
> 
> I couldn't see anything wrong with these and based on what I 
> read on the
> links, I wouldn't think the issue is in the Restlet code. 
> 
> Any other suggestions welcome.
> 
> Sean

Reply via email to