Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 14 of 14

Thread: proxy checker keeps freezing

  1. #1
    Member
    Join Date
    Apr 2013
    Posts
    83
    Thanks
    7
    Thanked 3 Times in 3 Posts

    Default proxy checker keeps freezing

    hi i am trying to build a proxy checker i am doing this by pinging a site for 6 secs ti check for response and this all works fine the problem is that once i have checked about 20-25 proxies netbeans freezes and nothing else happens the program is not treaded yet but i cant figure out why this keeps happening does anyone have any ideas help would be appreciated as i am a newb at a loss the program works but just freezes after a while which renders it useless thanks


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: proxy checker keeps freezing

    At What statement in the code is the program freezing?
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Member
    Join Date
    Apr 2013
    Posts
    83
    Thanks
    7
    Thanked 3 Times in 3 Posts

    Default Re: proxy checker keeps freezing

    none it check proxies and sets boolean fine then it just stops i get no error messages or anything it just freezes

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: proxy checker keeps freezing

    it just stops
    Two basic choices:
    the program is in an infinite loop
    the code is blocked waiting for an event

    Add lots of println statements to see which case it is.
    If a loop, where is it looping
    If blocked, what statement did it start executing and never finish executing.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Member
    Join Date
    Apr 2013
    Posts
    83
    Thanks
    7
    Thanked 3 Times in 3 Posts

    Default Re: proxy checker keeps freezing

    i dont think its system related as my ubuntu system monitor aint going crazy and the rest of cpu is still going fine it allso freezes at a random number of proxies around 20-25 then it just stops priniting results the little oraange bar at the bottom of netbeans stops and nothing happens after that

    --- Update ---

    Quote Originally Posted by Norm View Post
    Two basic choices:
    the program is in an infinite loop
    the code is blocked waiting for an event

    Add lots of println statements to see which case it is.
    If a loop, where is it looping
    If blocked, what statement did it start executing and never finish executing.
    but its just doing the sasme thing over and over if it was a problem with loop or anything it wouldint check the second proxy it would stick on first
    the programe fills an ARRAYLIST AAAAAH maybe im loading to many proxyies at once ill shorten list and try brb

    --- Update ---

    no i was loading over 6k proxies into arraylist but have shortened it to 70 but now freezing at 3 proxies

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: proxy checker keeps freezing

    what statement is it stopping/freezing at?
    If you don't understand my answer, don't ignore it, ask a question.

  7. #7
    Member
    Join Date
    Apr 2013
    Posts
    83
    Thanks
    7
    Thanked 3 Times in 3 Posts

    Default Re: proxy checker keeps freezing

    Quote Originally Posted by Norm View Post
    what statement is it stopping/freezing at?
    k think i found the problem my code checks socks proxy proxies im using might not be sock proxys oops my stupidity gota hit the google to determine what protocol a proxy is when all you have is the ip:port? or if anyone here knows plz save me an hour otherwise ill post what i fin thanks

  8. #8
    Member
    Join Date
    Apr 2013
    Posts
    83
    Thanks
    7
    Thanked 3 Times in 3 Posts

    Default Re: proxy checker keeps freezing

    k still havint found the solution
    the code is
         SocketAddress addr = new InetSocketAddress("119.73.3.76", 8118);//this is not sock it is http
          Proxy proxy = new Proxy(Proxy.Type.SOCKS, addr); 
          boolean res=false;
     try{
        URL site = new URL("http://www.google.co.uk");
        HttpURLConnection inSite = (HttpURLConnection) site.openConnection(proxy);
        inSite.setConnectTimeout(9000); // mTimeout is in seconds
        inSite.connect();//connects site
                if (inSite.getResponseCode() == HttpURLConnection.HTTP_OK) {//test
                    res= true;
                }else if (inSite == null) {
                   System.out.println("istrm == null");
                }   
         }catch (Exception e1) {
           System.out.print("error");
        }   
        System.out.println(res+""+proxy);
     
        }
    }
    if i use a sock proxy this cod works fine but if its a different protocl lke http then i just freezes no error no op at all can anyone spot a way to place a trigger or throw an exception so i can then use that to trigger a differnt proxy setting thanks

  9. #9
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: proxy checker keeps freezing

    Please edit your post and wrap your code with code tags:
    [code=java]
    <YOUR CODE HERE>
    [/code]
    to get highlighting and preserve formatting.

    What statement does the code stop execution at?
    If you don't understand my answer, don't ignore it, ask a question.

  10. #10
    Member
    Join Date
    Apr 2013
    Posts
    83
    Thanks
    7
    Thanked 3 Times in 3 Posts

    Default Re: proxy checker keeps freezing

    it seems to stop at
    inSite.connect();
    so it must keep trying to connect and never give up if its the wrong protocol cos if its socks and the sock doesint work it allso wouldint connect but then it breaks after 9sec ping and trys the next

  11. #11
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: proxy checker keeps freezing

    Sorry, I've never worked with proxies and have no ideas about the problem.
    If you don't understand my answer, don't ignore it, ask a question.

  12. #12
    Member
    Join Date
    Apr 2013
    Posts
    83
    Thanks
    7
    Thanked 3 Times in 3 Posts

    Default Re: proxy checker keeps freezing

    just an update .. iwent for a cup of coffe and when i came back it had finished running but it took 20ish min to timeout but the timeout is set to 9sec why doeint it time out no matter what protocol is used is a mistery to a newb like myself but its a real pain

  13. #13
    Member
    Join Date
    Apr 2013
    Posts
    83
    Thanks
    7
    Thanked 3 Times in 3 Posts

    Default Re: proxy checker keeps freezing

    k if anyone knows the answer to this would be great if you could reply cos it has me at a dead end but i found this code on the web that checks if a proxy is sock or http so with a bit of editing can work for me and i tought id post it here on case someone else needed it
     public static void main(String[] args) throws IOException {       
            InetSocketAddress proxyAddress = new InetSocketAddress("127.0.0.1", 9050);
            Proxy.Type proxyType;
            proxyType = detectProxyType(proxyAddress);
            System.out.println(proxyAddress + " is a " + proxyType + " proxy.");
        }
        public static Proxy.Type detectProxyType(InetSocketAddress proxyAddress)throws IOException{
            URL url = new URL("http://www.google.com");
            List<Proxy.Type> proxyTypesToTry = Arrays.asList(Proxy.Type.SOCKS, Proxy.Type.HTTP);
            for (Proxy.Type proxyType : proxyTypesToTry){
                Proxy proxy = new Proxy(proxyType, proxyAddress);
                URLConnection connection = null;//Try with SOCKS
                try{
                    connection = url.openConnection(proxy);
                    //Can modify timeouts if default timeout is taking too long
                    //connection.setConnectTimeout(1000);
                    //connection.setReadTimeout(1000);
                    connection.getContent();
                    //If we get here we made a successful connection
                    return(proxyType);
                }catch (SocketException e) {//or possibly more generic IOException?
                    //Proxy connection failed
                }
            }
            //No proxies worked if we get here
            return(null);
        }
    }
    i didint write this code so hope its ok to post

    --- Update ---

    k if anyone knows the answer to this would be great if you could reply cos it has me at a dead end but i found this code on the web that checks if a proxy is sock or http so with a bit of editing can work for me and i tought id post it here on case someone else needed it
     public static void main(String[] args) throws IOException {       
            InetSocketAddress proxyAddress = new InetSocketAddress("127.0.0.1", 9050);
            Proxy.Type proxyType;
            proxyType = detectProxyType(proxyAddress);
            System.out.println(proxyAddress + " is a " + proxyType + " proxy.");
        }
        public static Proxy.Type detectProxyType(InetSocketAddress proxyAddress)throws IOException{
            URL url = new URL("http://www.google.com");
            List<Proxy.Type> proxyTypesToTry = Arrays.asList(Proxy.Type.SOCKS, Proxy.Type.HTTP);
            for (Proxy.Type proxyType : proxyTypesToTry){
                Proxy proxy = new Proxy(proxyType, proxyAddress);
                URLConnection connection = null;//Try with SOCKS
                try{
                    connection = url.openConnection(proxy);
                    //Can modify timeouts if default timeout is taking too long
                    //connection.setConnectTimeout(1000);
                    //connection.setReadTimeout(1000);
                    connection.getContent();
                    //If we get here we made a successful connection
                    return(proxyType);
                }catch (SocketException e) {//or possibly more generic IOException?
                    //Proxy connection failed
                }
            }
            //No proxies worked if we get here
            return(null);
        }
    }
    i didint write this code so hope its ok to post

  14. #14
    Member
    Join Date
    Apr 2013
    Posts
    83
    Thanks
    7
    Thanked 3 Times in 3 Posts

    Default Re: proxy checker keeps freezing

    k so basically i had to use executerService to time the action and time it out its a pain that i never found out why connection time out failed but how and ever its working here is code

    try{executor = Executors.newSingleThreadExecutor();
                Future<String> future = (Future<String>)executor.submit(new pingcheck(h));
                future.get(10, TimeUnit.SECONDS);

Similar Threads

  1. [SOLVED] Checker Program
    By maxreed in forum What's Wrong With My Code?
    Replies: 6
    Last Post: November 14th, 2012, 05:58 PM
  2. how to add Spell checker
    By hope2012 in forum Java Theory & Questions
    Replies: 1
    Last Post: November 8th, 2012, 08:23 AM
  3. Spell checker using bags
    By kovynjd2010 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: September 16th, 2012, 12:09 PM
  4. Problem with Java Update freezing application
    By banny7 in forum Java Theory & Questions
    Replies: 0
    Last Post: October 25th, 2011, 12:36 PM
  5. Freezing on bust (BlackJack)
    By DaffyPWNS in forum What's Wrong With My Code?
    Replies: 9
    Last Post: June 16th, 2011, 09:40 PM