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
Did you know?Explore Trending and Topic pages for more stories like this.
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

Blogging s/w
heya frndz!!! i want to start a blog.... m looking for a s/w like oscommerce which is thr for e-comm

images aren't rendering
I'm trying to call a JPG file from within PHP (in an effort to hide the actual JPG folder). The imag

how to insert value
I am having file bookissueadd.php..... in which i am having tag

<td height="21&q

Trouble checking SESSION cookie
I am trying to use $_SESSION cookies to verify admin privileges .
I don't understand why this is

HTML Email rec'd as Source Code
The code does create and send the email successfully. However, the message shows as html code and n

Inserting the current date/time while submitting the forum
What do I need to add below to update the current date/time? I have a field in the database called d

Problem with umlauts and UTF-8
Hello every1,

I'm creating my own little CMS at the moment and got some problems with the cha

type check while uploading
Hi Everyone,

How can I check the exact type of a file while uploading on my site?

Here

php web service error
hey guys,
I'm working on a project requires the use of web services. I've been trying a few tutor

PHP Form to Variable.
Hi! I have written a HTML-form code in DreamWeaver CS3 (in a PHP doc) and I really need it to work s

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