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

Production Order Enterprise Service to Manufacturing Exctn Sys (MES) ???
Hello Experts,

In our current landscape SAP ECC 5.0 is integrated to MES system via PI 7.

Problems with strings containing
Hey all,

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

DBCA Templates
Hi all,

I'm working on creating a template for DBCA, but can't find any documentation on the

Time script, set to my time zone?
I am using this line to get the date and time

Code: $time = date(F." ".d.", &q

remove trailing slash from array
I have the following array which contains trailing slashes I need to remove. What is the best way to

problems with script
I made a small script wich exchanges points in my website:


<?php
session_start

How do I use a global footer..?
If my index.php has a bole bunch of if functions and exit's in them

[Need Help] php timing issues
I don't know what is going wrong. I need some help with being able to set an image at 9:00am Colorad

reading partial code from external site
Hi,

I am trying to write a script for my website to get an article from an external website.

mail with attachment problems
Hi. I have the following code:
Code: else if(file_exists("site".$timp.".zip")

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