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

how to read and write into a word document using php...?
hi,
I need,reading and writting into a word document using php.




Thank u inadva

if description does not contain the following words
Hello everyone,

I am parsing a MS Excel (.xls) file and adding it's content to a mySQL databa

Backflush
I am looking for a report in SAP that would give me a list of all parts that are populated with a ba

Echoing If Function?
A script I am using has If statements in the comments form to basically tell the form what to do. Cu

How can you detect variable string in a massive string?
Ok guys, i need some help with this one.

I am going to be getting a large string, like 10-20

Help With editting and deleting form
So look at this image :

http://img194.imageshack.us/img194/8272/snapshot5f.png
This table

Members Only
Hi all, for my website i have a members area only which on members can veiw, but at the moment anyon

Generating unique numbers using php
Hi,
I need help in generating unique number using php.I tired using rand() in php.But, by using r

User registration and login
I don't know whether this is the correct forum, if not i apologise but am pretty desperate at the mo

values in array being escaped
I would like to submit some values - back to the same form for checking before processing...

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