How to implement HTTP connection timeout


Posted on 16th Feb 2014 07:03 pm by admin

Hi All,I would like to implement an HTTP connection timeout.

I am working on a application which uses HTTP connection,
but the problem here is that the response from server
is late... I want to create a timeout against HTTP
request such that if response doesn't come within sec
then the connection should get closed.

Please let me know how I can implement this.

Code is like:

HttpConnection connection = null;
connection = (HttpConnection) Connector.open(getURL(), Connector.READ);
int responseCode = connection.getResponseCode();

I am receiving response code almost after 2-3 sec.. and
sometimes 1-2 mins too, which makes my application hang.

I want to create a timeout for such situation, Please let
me know how I can implement.. "connection" variable is
a local variable.

Thanks

No comments posted yet

Your Answer:

Login to answer
93 Like 35 Dislike
Previous forums Next forums
Other forums

Page Reload
I am having issues getting a page to reload after I submit data to a database. This form should inp

Got A Free Server :(
So I was given a free server

http://shopping.yahoo.com/p:Compaq%20ProLiant%201500%20Server:1

Displaying a record from mysql in a simple swf file
Hi,

I have a mysql database containing information I would like to display in my swf.

Hyperlink is adding an extra gap to variable
Hi, here's my problem..

I have a php generated page with a hyperlink which opens in a new win

Opening Multiple Files/Links in Order.
I want to open links in order/one-by-one and check each for a specific string.

Example:
I

Array to string conversion
Can anyone help me with this?

Notice: Array to string conversion in /home/..../index.php on l

Print 'a' to 'z' via for loop
A very simple problem..
How Can I print a to z NOT a to y ?
It is a part of a code where
<

PHP Search Issue
Hi, I am using the following code to search and return flights from a database. The user searches by

Does deleting the spmlog directory critical?
Hi Everyone,

Please, hope you could help me. We're having problems with the SAP backup. I

What are causes of a connection-timeout with fopen()?
Hello! Here is the situation: The server I host my website on just upgraded it's PHP build from 4.4.

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash