Link to home
Start Free TrialLog in
Avatar of bjornsone
bjornsone

asked on

Several simultaneous URLConnections to a single server

I have a java application using Sun's JDK 1.4 which opens
several URLConnections to our server.  Some of these take
the server a long time to generate a response, and sometimes
the client has several that occur at the same time.

It appears that java does not allow them to all happen in parallel.
Perhaps java may be trying to reuse the same socket connection
for processing each http request in serial.  With some of my slow
responses, however, this default limitation on parallel URLConnections
is really making things unacceptably slow.

Is there any way I can change the configuration so that there is
1. No small limit to the number of simultaneous connections
2. Even if some of the responses are slow, the other responses don't
    have to wait.

Thanks a lot
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

You're presumably handling them in separate threads? If not, that's what you should do
Avatar of ggalvao
ggalvao

Make your URLConnection class implement Thread interface then use methods .start() to dispatch the connection code.
Avatar of bjornsone

ASKER

Yes, I am using separate threads, but java somewhere at a lower
level has restrictions on how it handles multiple URLConnections to
the same server.
>>
but java somewhere at a lower
level has restrictions on how it handles multiple URLConnections to
the same server.
>>

What's your OS and how many open connections have you got?

It runs on windows 2000 and windows xp
I can't set an absolute maximum that our application
may be using at once, but it should typically not
exceed 5.
>>I can't set an absolute maximum that our application may be using at once

You certainly can set a maximum number of threads and should. 5 would be absolutely fine. You should probably set a timeout and an exception will be thrown, allowing the thread to exit
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Clarification:

In

HOST: <your host>\r\n

<your host> means the name of your server like www.microsoft.com
Thanks alot
8-)