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

file downloaded can't be read !!
<?php
$fileName = 'mypic.jpg';
$mimeType = 'image/jpeg';
header('content-dispositio

how to validate date using javascript
I need to validate date in textbox using javascript..
The date is must be not greater than TODAY

do while conditions
i want to display 6 images in a 2x3 table
now what would be the correct logic to
count that th

convert static html data into dynamic
hi all

i need to convert a website which has static above 2000 articles into dynamic and add

reading xml faster than DB call?
I am trying to optimize a high traffic website, and I enabled a feature where there are three photos

Troubles with a spider class
I am building a spider that will crawl through random whitepages (eg. anywho.com, switchboard.com, w

Multiple upload and Resize
I would like some help on my script I have the for my index.php

////

<html&

Sending CC Info by email
I am a little bit less knowledgable in the security area as most developers and I know I have a lot

Why does my php page download images over and over
Can anybody please explain to me why my php page keeps downloading the images and other items every

How to give the privillege for triggers?
Hi,

How to give the privillage for triggers to particular user?

Please let me

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