Wednesday, August 25, 2010

Java URL connection timeout - default timeout might save you from hanging

Many times, when you make a url connection or any connection that works over tcp ip (ftp, http etc) protocol, it is possible that your client just hangs.  It is frustrating to debug this kind of issue because, you do not get any exception from your application except it just hangs.  This can be a problem especially in production environments where there are firewalls between every single component and it is hard to trace network traffic.   

If you are using sun jdk.1.4 or above there is a way you can prevent your code from just hanging.  Best of all, you do not even have to make a code change.  The sun jvm has a way to specify default timeout values for the net client.   All you have to do is just add the following java parameters to the command line that starts your application. 
This will force the client to timeout and hopefully your application logs the exception that gives enough clue to debug the issue.   For more information about specifying network properties in java check out the Networking Properties guide from sun/oracle.


buy dissertation said...

First, we expect our future author to have a University degree and at least 2 years of expertise in custom writing. Nevertheless grade miners, many of them hesitate to order their essays online because they are afraid to get caught for cheating.

Lilla Wilkinson said...

Hiya! Order essays from and forget about your academic worries. Feel free to look over the completed paper and ask your essay writer any questions. We won't be satisfied until you are! Visit and get the best college essays today!

Goldyy said...

You can save good money when you order essays early. We are reliable custom essay writing service to buy essay cheap from college papers. The student is unsure on the topic at hand, so they want to hire an order essay service to ensure they don't affect their grades.

Tommy543 said...

“How will you write my paper for free or at a fee?” Our customers often want to know how well we do their work. To demonstrate our commitment to your satisfaction, we have several assurances. For one, we guarantee you free revisions on all orders. Request a correction for free within 14 days if you feel like the work needs some improvements.