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
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

Problems with strings containing
Hey all,

I have encountered something strange in a script. I am trying to write an XML heade

Find current logon time
Hi,
in my sql script i want to query and find out the logon time of the current session.
<

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

How do I give a developer access to a specific directory and nothing else?
I want to give a develop access to a specific directory and nothing else

I can give them an F

mail() problem
Hi Guys,

I've set up a contact email form. It sends the information fine, but it sends it to

HTML form problem
Ive made a form to that i want to send to my email via PHP. but when it send only the name's etc sen

PHP Function Page Advice
Hi All, I am quite new to PHP and Javascript but have written an Online Shop (Mainly for Fun and edu

Add_Months not Easy to Understand
Oracle is number 1, very fast and very easy. But....
OK, I think but have a problem, only 1 pro

Upload simple problem
Really confused!! I run once and it worked, but when i tried today...it didn't work

Which par

Comparing two dates
Hi Guys
I have two dates I want to compare. Below is my current implementation. The problem with

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