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

Easy administration on MySQL databases
My website is database driven and I am very tired of manually making queries to my tables in order t

UPLOAD IMAGES NOT WORKING!
Hi there i have a upload script in which it uploads the picture to a folder than creates two thumbna

Linked Keywords
I am trying to get a script that makes my predefined keyword converted to links and / or converted t

Session login issue
I'm wondering how to fix a problem I'm having with a session-based login system

Say I go to h

MFC GUI Programming
I am working on a project right now that requires me to create a MFC Windows GUI. Basically it need

Need Help with a query
Hello,
For some reason I am just not getting the right answer when I do this query and not quite

Amatuer requiring assistance
Beginner and amateur in need of assistance

My Site - (Spare Parts for Domestic Appliances)

Multiple while loops
I have several DB queries that I know should be returning results and aren't. I have a feeling it ha

passing data from one page to another
hey guys
i have the follwoing code to get information from one page and place on another:

Form validation with functions
Hi there

I am trying to make a very simple form validation function. I currently have the fol

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