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

GIS appliction help
I found some tutorials in the internet to develop a map application I don't want to use google maps

Weird Problem with curl while sending data
I am facing a weird problem with sending data to a site via curl.

If i send the value by this

send message to the java application
Oracle 10g with Windows platform.

I have a java application that periodically pings the d

Do While statement
hi guys,

This may sound trivial but im new to php and as part of an assignmenti have to const

Breaking results into week blocks
I have a set of dates (and times), which are returned from a mySQL query.

These usually span

using variables in another page
I have a test database set up on localhost. I have a form that I can type a name into, hit the butto

Need help with an email blocker for a guessbook
I am new with php and here is a simple guessbook page but I am being hit with spam from a group of t

How to know if online site made with PHP
Hello,
I see some sites that does not display extensions at all , for example:

www.site.co

image upload, resize THEN submit form
Ok so I have a form that requires the user to upload an image, and then do something with that image

Can't find the problem (no error message)!
OK, here's the deal. This code is really weirdly formatted (sorry!) and hard to understand, so I'm g

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