Results 1 to 3 of 3
Thread: HTTP Connection timeout issue
- 08-28-2012, 06:09 AM #1
Member
- Join Date
- Jul 2011
- Posts
- 32
- Rep Power
- 0
HTTP Connection timeout issue
I am wondering if anyone knows how I can prevent this error from happening. I am trying to schedule the program to run once an hour, sometimes it works, other times it does not.
Thanks in advanceJava Code:public static void main(String[] args) throws Exception{ Socket clientSocket = null; URL a = null; try { a = new URL("http://ip/"); } catch (MalformedURLException e) { e.printStackTrace(); } try{ //reading in the data from the url directly into the console to see all results returned new BufferedReader(new InputStreamReader((a.openStream()))); //creating a new socket connection. clientSocket = new Socket("ip", 80); }catch(UnknownHostException error){ error.printStackTrace(); System.exit(1); }catch(Throwable e){ e.printStackTrace(); System.exit(1); } SAXParserFactory sax = SAXParserFactory.newInstance(); try{ SAXParser saxParser = sax.newSAXParser(); XMLReader XMLReader = saxParser.getXMLReader(); XMLReader.setContentHandler(new NorthCommander()); XMLReader.parse(new InputSource(a.openStream())); }catch(Throwable e){ e.printStackTrace(); System.exit(1); } clientSocket.close(); }Last edited by alexandra12; 08-29-2012 at 03:11 AM.
- 08-29-2012, 01:05 AM #2
Re: HTTP Connection timeout issue
Hi! Please use [code][/code] when post code so we can read it easily!
That said, I don't see any loops, timers, etc... that would allow this program to run once an hour. You need to either add a long sleep statement, or use a java Timer to schedule the interval.
- 08-29-2012, 03:13 AM #3
Member
- Join Date
- Jul 2011
- Posts
- 32
- Rep Power
- 0
Re: HTTP Connection timeout issue
hi quad64bit ,
I could not find the code option last night when submitting the thread. I was half asleep anyway. In reply to your comment - I am not using any java timers. I have created a runnable jar file. I then created a batch file that kicks off the above class in the jar file once an hour.
Are you able to offer any more advice ?
Similar Threads
-
capture db connection timeout error
By uthpalaw in forum JDBCReplies: 11Last Post: 09-09-2010, 11:45 AM -
Session Timeout issue
By maheshd1 in forum New To JavaReplies: 0Last Post: 08-23-2010, 11:34 AM -
Connection timeout exception
By wickedrahul9 in forum Advanced JavaReplies: 2Last Post: 11-13-2008, 08:32 AM -
RAD - Error getting connection: Timeout.
By ShoeNinja in forum Other IDEsReplies: 0Last Post: 09-09-2008, 05:25 PM -
Detect TimeOut in a HttpURL Connection
By Ed in forum Advanced JavaReplies: 2Last Post: 07-02-2007, 04:29 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks