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

insert/update functions for mysql, what do you think?
I am working on two really simple functions that automatically generate (and execute) insert and upd

Change Web page language
i doing this thing first time but i dont find any suitable solution for it. On the demand of user. I

php mail form text wont appear / javascript included
Guys/gals...

I am running into a problem whereby I have a great piece of javascript code that

a dificult string search
Hi I don't know a way around this. I want the user to input a password, but to make it a bit complca

Filename and Line Number Custom Error
I have a class, with a method that accepts 2 parameters. I would like to output error messages.

Pro-rata Billing in Periodic Billing for Rental
Hi guys,

We have a situation, where a rental contract starts at the mid of the month say

Is this Safe or Unsafe?
Hi i made a few pages with lots of peoples help now i just want to know if they are safe or not can

Table Control
Hi Guru's,

I've created a Module pool program, which contains the Table Control.

need Array help
This is what I have to do.
$teamname[1] = "Red Sox"
$teamname[2] = "Gian

show the direct link into href
I want to display link on the page. i am fetching the data(URL) from database,actually before that i

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