You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Gábor SEBESTYÉN <se...@gmail.com> on 2005/07/04 13:21:25 UTC
Painfully slow socket buildup on Java 1.5
Hi,
After resolving my proxy problem here's a new one. My applet built on
HttpClient 3.0r3 works well on Java 1.4.2 but on 1.5 it extremely
slows down and I get the following log entries:
network: Connecting socket://195.184.xxx.xxx:80 with proxy=DIRECT
[WARNING] slow HTTP response: 4.577 secs
network: Connecting socket://195.184.xxx.xxx:80 with proxy=DIRECT
[WARNING] slow HTTP response: 4.567 secs
network: Connecting socket://195.184.xxx.xxx:80 with proxy=DIRECT
[WARNING] slow HTTP response: 4.647 secs
network: Connecting socket://195.184.xxx.xxx:80 with proxy=DIRECT
[WARNING] slow HTTP response: 4.576 secs
Warnings are mine displaying the method.executeMethod() speed. And
it's terribly slow. Having about 5 seconds to do a simple request is
more than unacceptable. I repeat no such an error on Java 1.4.2 on
every platform ( Win / Mac / else :)) ).
Please help what causes this on Java 1.5. The version is 1.5.0 (build
1.5.0_02-b09 / Win2000).
Thanks,
Gábor
To be is to do. - Socrates
To do is to be. - Sartre
Do be do be do. - Sinatra
Re: Painfully slow socket buildup on Java 1.5
Posted by Gábor SEBESTYÉN <se...@gmail.com>.
On 2005.07.04., at 19:10, Michael Becke wrote:
> Just a guess, but it could be that 1.5 is resolving addresses
> differently.
I'm sure ... whatever :)
> You could run some test by connecting to URLs where the host name
> has already been resolved. For example try
> http://64.233.161.147/ instead of http://www.google.com/.
Well I do use IP number because host has no name yet.
> My guess is that the delay has to do with when socket is opened and
> connected to the remote host.
Do you think it does matter if I connect to a "local" proxy or a
remote site? Both requests will do name resolvation even the passed
parameter is an IP.
But thanks for your help :)
Gábor
"Everything begins with choice... "
Re: Painfully slow socket buildup on Java 1.5
Posted by Michael Becke <mb...@gmail.com>.
Just a guess, but it could be that 1.5 is resolving addresses
differently. You could run some test by connecting to URLs where the
host name has already been resolved. For example try
http://64.233.161.147/ instead of http://www.google.com/. My guess is
that the delay has to do with when socket is opened and connected to
the remote host. Frequently DNS resolution is the key to slowdowns in
this area.
Mike
On 7/4/05, Gábor SEBESTYÉN <se...@gmail.com> wrote:
>
> On 2005.07.04., at 18:44, Michael Becke wrote:
>
> > It could be a DNS issue. Have you tried connecting to IP hosts
> > instead of named hosts?
> >
> I have a broadband connection and an own DNS server working
> ordinarily. I cannot deal with DNS issue since no other software ever
> had any resolvation problem including slow resolves. Java 1.4.2 has
> no difficulties as well. Only Java 1.5.
>
> But what do you mean by "IP host"? A hand over a string containg an
> address or a name and I guess the underlying socket subsystem will
> perform a lookup either I passed an IP in string or a host name.
>
> Gábor
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
Re: Painfully slow socket buildup on Java 1.5
Posted by Gábor SEBESTYÉN <se...@gmail.com>.
On 2005.07.04., at 18:44, Michael Becke wrote:
> It could be a DNS issue. Have you tried connecting to IP hosts
> instead of named hosts?
>
I have a broadband connection and an own DNS server working
ordinarily. I cannot deal with DNS issue since no other software ever
had any resolvation problem including slow resolves. Java 1.4.2 has
no difficulties as well. Only Java 1.5.
But what do you mean by "IP host"? A hand over a string containg an
address or a name and I guess the underlying socket subsystem will
perform a lookup either I passed an IP in string or a host name.
Gábor
Re: Painfully slow socket buildup on Java 1.5
Posted by Michael Becke <mb...@gmail.com>.
It could be a DNS issue. Have you tried connecting to IP hosts
instead of named hosts?
Mike
On 7/4/05, Gábor SEBESTYÉN <se...@gmail.com> wrote:
> Additional info: if I setup proxy communication the chat works
> veeeery well on Java 1.5. Direct connection has this issue.
>
> Gábor
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
Re: Painfully slow socket buildup on Java 1.5
Posted by Gábor SEBESTYÉN <se...@gmail.com>.
Additional info: if I setup proxy communication the chat works
veeeery well on Java 1.5. Direct connection has this issue.
Gábor
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
Re: Painfully slow socket buildup on Java 1.5
Posted by Gábor SEBESTYÉN <se...@gmail.com>.
On 2005.07.04., at 17:24, Michael Becke wrote:
> I don't know of any issues with HttpClient and java 1.5, but I also
> do not know how many people are using the two.
Well the fact is that I develop a chat applet using HttpClient on Mac
with Java 1.4.2. Works pretty well. Also works well on Windowses with
1.4.2. But on WinXP / Win2000 with Java 1.5 experienced a major slow
down. I've wrote a timer around each method.execute..() and all
measures showed about 4.5 secs per request with or without using
(basic) proxy! But only on Windows. On Mac there's no problem with
1.5 at all!
> Could you put together some sample code that exhibits this problem?
Hardly :( But here's the main method which does the important part.
It's anyway made of an original example :)
public boolean post(String actionName, NameValuePair[] params) {
boolean ret = false;
synchronized(commLock) {
HttpClient client = new HttpClient();
// Create a method instance.
PostMethod method = new PostMethod(baseURL + "/" + actionName);
method.setRequestBody(params);
// Provide custom retry handler is necessary
method.getParams().setParameter
(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(3,
false));
method.getParams().setContentCharset("UTF-8");
try {
// Execute the method.
long t0 = System.currentTimeMillis();
int statusCode = client.executeMethod(method);
long t1 = System.currentTimeMillis();
// debug
if (t1 - t0 > 4000) {
double dt = ((double)t1-t0)/1000;
System.out.println("[WARNING] slow HTTP response: "
+ dt + " secs");
}
if (statusCode != HttpStatus.SC_OK) {
System.err.println("Method failed: " +
method.getStatusLine());
handler.showHTTPError(new String
(method.getResponseBody(), "UTF-8"), statusCode);
} else {
// Read the response body.
StringBuffer sb = new StringBuffer();
BufferedReader in = new BufferedReader(new
InputStreamReader(method.getResponseBodyAsStream(), "UTF-8"));
String line;
try {
while ((line = in.readLine()) != null) {
sb.append(line);
}
} catch (IOException exc) {
}
lastResult = sb.toString();
sb = null;
}
ret = true;
} catch (HttpException e) {
System.err.println("Fatal protocol violation: " +
e.getMessage());
// e.printStackTrace();
} catch (IOException e) {
System.err.println("Fatal transport error: " +
e.getMessage());
// e.printStackTrace();
} catch (SecurityException e) {
System.err.println("Security error: " + e.getMessage());
} finally {
// Release the connection.
method.releaseConnection();
}
}
return ret;
}
> Also, do you know where the stall is happening: opening the
> connection, writing the request, reading the response?
I don't know but I've read somewhere that this issue is related to
the opening, especially to resolving host address. I don't think
resolving is the clue because the same operation works lightning-fast
with Java 1.4.2. So no idea at all.
> Are you using SSL perhaps?
>
Actually no, but planned to use.
Gábr
"In God we trust, all others we virus scan."
Re: Painfully slow socket buildup on Java 1.5
Posted by Michael Becke <mb...@gmail.com>.
Hi Gábor,
I don't know of any issues with HttpClient and java 1.5, but I also do
not know how many people are using the two. Could you put together
some sample code that exhibits this problem? Also, do you know where
the stall is happening: opening the connection, writing the request,
reading the response? Are you using SSL perhaps?
Mike
On 7/4/05, Gábor SEBESTYÉN <se...@gmail.com> wrote:
> Hi,
>
> After resolving my proxy problem here's a new one. My applet built on
> HttpClient 3.0r3 works well on Java 1.4.2 but on 1.5 it extremely
> slows down and I get the following log entries:
>
> network: Connecting socket://195.184.xxx.xxx:80 with proxy=DIRECT
> [WARNING] slow HTTP response: 4.577 secs
> network: Connecting socket://195.184.xxx.xxx:80 with proxy=DIRECT
> [WARNING] slow HTTP response: 4.567 secs
> network: Connecting socket://195.184.xxx.xxx:80 with proxy=DIRECT
> [WARNING] slow HTTP response: 4.647 secs
> network: Connecting socket://195.184.xxx.xxx:80 with proxy=DIRECT
> [WARNING] slow HTTP response: 4.576 secs
>
> Warnings are mine displaying the method.executeMethod() speed. And
> it's terribly slow. Having about 5 seconds to do a simple request is
> more than unacceptable. I repeat no such an error on Java 1.4.2 on
> every platform ( Win / Mac / else :)) ).
>
> Please help what causes this on Java 1.5. The version is 1.5.0 (build
> 1.5.0_02-b09 / Win2000).
> Thanks,
>
> Gábor
>
>
> To be is to do. - Socrates
> To do is to be. - Sartre
> Do be do be do. - Sinatra
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org