Results 1 to 3 of 3
  1. #1
    alexandra12 is offline Member
    Join Date
    Jul 2011
    Posts
    34
    Rep Power
    0

    Default 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.
    Java 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();    
    		        
    		             
    		}
    Thanks in advance
    Last edited by alexandra12; 08-29-2012 at 04:11 AM.

  2. #2
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

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

  3. #3
    alexandra12 is offline Member
    Join Date
    Jul 2011
    Posts
    34
    Rep Power
    0

    Default 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

  1. capture db connection timeout error
    By uthpalaw in forum JDBC
    Replies: 11
    Last Post: 09-09-2010, 12:45 PM
  2. Session Timeout issue
    By maheshd1 in forum New To Java
    Replies: 0
    Last Post: 08-23-2010, 12:34 PM
  3. Connection timeout exception
    By wickedrahul9 in forum Advanced Java
    Replies: 2
    Last Post: 11-13-2008, 09:32 AM
  4. RAD - Error getting connection: Timeout.
    By ShoeNinja in forum Other IDEs
    Replies: 0
    Last Post: 09-09-2008, 06:25 PM
  5. Detect TimeOut in a HttpURL Connection
    By Ed in forum Advanced Java
    Replies: 2
    Last Post: 07-02-2007, 05:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •