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

Checking if multidimensional array is empty?
I have a for with multiple test input fields. Specifically the user submits multiple names and ages

Update data to upper case in parent/child tables
Hi Gurus!

In production we have a product table and which is being reference by many tabl

Deleting a record php
Attempting to setup delete a record page. The below code I put together doesn't seem to work.

form submit at godaddy?
Trying to test form submission at GoDaddy and it does not seem to work. Here's the page...

h

error with opendir
when i do this

if ($handle = opendir($dir)) {
while (false !== ($file = readdir($han

Get dump of MySQL DB from Live Site
I'm after an easy, but secure way of generating and importing a MySQL dump from a remote server.

get font info from a font file
hello,

Does anyone know how to get font info from a font file ... using php of course !
<

Loop column after 2 results
Hello All.

Here is what I have:

Client ID Company name Clien

Transport data between itab and textfield on ALV event
Hallo,

I have a ALV Grid ( cl_gui_alv_grid ) and I also have hotspot click event with a h

Displaying image pathname instead of image
Hello

Im trying to upload and then display images from a mysql database - Its only basic and

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