Facing problems with URLConnection under high load

Hi,

I have a piece of code that acts as a load balancer. Under high load scenario - 200+ different simulataneous users, it throws some errors.

Following is a snippet from that code -

URL url = new URL(site);

URLConnection urlconnection = url.openConnection();

urlconnection.setDoInput(true);

urlconnection.setDoOutput(true);

urlconnection.setUseCaches(false);

DataOutputStream dataoutputstream =

new DataOutputStream(urlconnection.getOutputStream());

dataoutputstream.writeBytes(posServiceRequest);

dataoutputstream.flush();

dataoutputstream.close();

InputStream inputstream = urlconnection.getInputStream();

httpservletresponse.setContentType(urlconnection.getContentType());

rewriteStreams(inputstream, httpservletresponse.getOutputStream());

inputstream.close();

-

Somewhere after around 200 odd users, this piece of code throws an error - "Error writing to server", a stacktrace print shows that the error occurs at the following line -

InputStream inputstream = urlconnection.getInputStream();

Any pointers would be appreciated.

Thanks,

-rahul

[1189 byte] By [RahulSachdeva] at [2007-11-27 7:58:07]
# 1
More information please. What is the exception class, what is its entire text, and what is the stack trace.
ejpa at 2007-7-12 19:40:00 > top of Java-index,Core,Core APIs...