views:

749

answers:

3

I am writing an internal Java Applet to do file uploads via HTTP. I started using the built in ClientHttpRequest which worked great if I want to post one after another. When I try to have multiple threads post at the same time, something on the server side freaks out and the connection will hang for large files while still uploading the smaller files. (Large seems to be around 10 megs) After lots of looking, I would not able to find a timeout that I could set to recover from this error, but finally found ClientHttp from Apache which DOES provide a mechanism to set a timeout. The problem with it is that while it claims to be able to work in a multi-threaded program, it actually only does one request after another. I have found lots of example code for HttpClient which says it will work for multiple threads and have made adjustments to my code to incorporate those changes, but none of them make any difference, and I am still stuck with essentially 1 thread.

While multiple threads really are not required for release (HttpClient does seem to be a bit faster than ClientHttpRequest), it would be really nice to get that extra speed boost since there are a lot of smaller files that could be sent at the same time.

The files are being sent over HTTP because we want to use the same authentication of the already logged in user using their session cookies.

So I am looking for either a way to set a timeout with ClientHttpRequest or code for HttpClient that will actually send multiple requests at the same time as promised.

I am sharing the same HttpClient instance between threads and using the multithreaded connection manager (it won't even work without this) like the docs say and it doesn't help.

Any help would be appreciated and let me know if you need any clarifications.

+1  A: 

Seeing a sample of your code might help.

Perhaps the problem is the applet environment. Are you testing it in appletviewer, IDE, or in the browser? Browsers are generally setup to limit the number of connections to the same web server to 2. You might try adding a main() and running it standalone to see if that fixes the problem.

KC Baltz
A: 

Show the source pls

Vugluskr
A: 

The apache HttpClient user group mailing list might be a better bet at solving this than this forum. YMMV.

anjanb