504 error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • freddieMaize
    New Member
    • Aug 2008
    • 85

    504 error

    Hi all,

    I used the below,
    Code:
    InputStream in = new URL ("http://127.0.0.1/search?q=travel") .openStream () ;
    I'm getting the below,
    [HTML]java.io.IOExcep tion: Server returned HTTP response code: 504 for URL: http://127.0.0.1/search?q=travel[/HTML]

    I've also set the proxies. Also, for your information, when i just chang the url to yahoo.com, its working fine.

    Any inputs would help me.

    Thanks,
    fREDDIE

    Out of the box question: I started a thread under networking. Is there a way to move it to somewhere else? May be here??
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Do you have a web server or servlet container etc. running on your local host on
    your default port (80)?

    kind regards,

    Jos

    Comment

    • freddieMaize
      New Member
      • Aug 2008
      • 85

      #3
      Originally posted by JosAH
      Do you have a web server or servlet container etc. running on your local host on
      your default port (80)?
      Hi JosAH, i'm actually using those in a standalone java program. So no servlets or web servers are in picture. Sorry i forgot to tell this in the first post.

      fREDDIE

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        Originally posted by freddieMaize
        Hi JosAH, i'm actually using those in a standalone java program. So no servlets or web servers are in picture. Sorry i forgot to tell this in the first post.
        But then it can never work because you explicitly state that you want to use the
        http protocol on your local host (default port 80). There is nothing listening on
        that port. If you change your url to point to the yahoo site it works because
        yahoo does have such a server available.

        kind regards,

        Jos

        Comment

        • freddieMaize
          New Member
          • Aug 2008
          • 85

          #5
          Originally posted by JosAH
          But then it can never work because you explicitly state that you want to use the
          http protocol on your local host (default port 80). There is nothing listening on
          that port. If you change your url to point to the yahoo site it works because
          yahoo does have such a server available.
          I would again apologies. Oh god why am i doing this.

          The actual url that i used was something like below,

          Code:
          InputStream in = new URL ("http://Anothermachine/search?q=travel") .openStream () ;
          To make sure that i dont show up the ip of the server machine that i use (just to be on the safer side) i gave localhost. My mistake.

          fREDDIE

          Comment

          • r035198x
            MVP
            • Sep 2006
            • 13225

            #6
            The same question that you were asked by Jos holds for that other machine of yours. If there is a server running there then make sure there are no security restrictions blocking access to the port you are trying to get to.

            Comment

            • freddieMaize
              New Member
              • Aug 2008
              • 85

              #7
              Originally posted by r035198x
              The same question that you were asked by Jos holds for that other machine of yours. If there is a server running there then make sure there are no security restrictions blocking access to the port you are trying to get to.
              Hi, But the url is accessible from my machine if i use it in the address bar. That is how we check if the server is up right? Kindly correct if i'm wrong.

              I'll put it in simple terms. If a url works in my browser then obviously i should be able to use that url in my application right?

              fREDDIE

              Comment

              • r035198x
                MVP
                • Sep 2006
                • 13225

                #8
                Originally posted by freddieMaize
                Hi, But the url is accessible from my machine if i use it in the address bar. That is how we check if the server is up right? Kindly correct if i'm wrong.

                I'll put it in simple terms. If a url works in my browser then obviously i should be able to use that url in my application right?

                fREDDIE
                OK then. It's purely a timing out issue then. When you try from the browser, you put exactly the same url as the one in the code right?

                Comment

                • freddieMaize
                  New Member
                  • Aug 2008
                  • 85

                  #9
                  Originally posted by r035198x
                  OK then. It's purely a timing out issue then. When you try from the browser, you put exactly the same url as the one in the code right?
                  Exactly the same. In fact i used ctrl+c and ctrl+v.

                  Comment

                  • r035198x
                    MVP
                    • Sep 2006
                    • 13225

                    #10
                    Originally posted by freddieMaize
                    Exactly the same. In fact i used ctrl+c and ctrl+v.
                    Just trying to eliminate another doubt with your proxy ...

                    Instead of openStream(), try using openConnection( aProxy).getInpu tStream();
                    For the aProxy part, first try Proxy.NO_PROXY. If that doesn't work then try creating a Proxy object using your proxy settings and use that instead.

                    Comment

                    • freddieMaize
                      New Member
                      • Aug 2008
                      • 85

                      #11
                      Originally posted by r035198x
                      Just trying to eliminate another doubt with your proxy ...

                      Instead of openStream(), try using openConnection( aProxy).getInpu tStream();
                      For the aProxy part, first try Proxy.NO_PROXY. If that doesn't work then try creating a Proxy object using your proxy settings and use that instead.
                      :( Unfortunatly that is also resulting the same. Below is the code with the latest changes,

                      Code:
                      System.getProperties().put("proxySet", "true");
                      	System.getProperties().put("proxyHost", "proxy");
                      	System.getProperties().put("proxyPort", "80"); 
                      
                              URL yahoo = new URL("http://172.16.1.21/search?q=travel");
                              URLConnection yc = yahoo.openConnection();
                              BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
                      I'm wondering why this 504 is comming.

                      fREDDIE

                      Comment

                      • r035198x
                        MVP
                        • Sep 2006
                        • 13225

                        #12
                        Try setting the proxy like I suggested without setting any System properties. See my post above again.

                        Comment

                        • freddieMaize
                          New Member
                          • Aug 2008
                          • 85

                          #13
                          Originally posted by r035198x
                          Try setting the proxy like I suggested without setting any System properties. See my post above again.
                          The below is what you were trying to say right?

                          Code:
                          SocketAddress addr = new InetSocketAddress("myProxy", 80);
                          	Proxy proxy = new Proxy(Proxy.Type.HTTP, addr);
                          	
                          	URL url = new URL("http://ServerMachine/search?q=travel");
                          	URLConnection yc = url.openConnection(proxy);
                          	BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
                          I initally tried with no proxy also, but then it dint work.

                          At end of all these attempts i'm still facing the same 504 error.

                          r035198x, is there anything else i'm missing from what you suggested?

                          fREDDIE

                          Comment

                          • freddieMaize
                            New Member
                            • Aug 2008
                            • 85

                            #14
                            Originally posted by freddieMaize
                            I initally tried with no proxy also, but then it dint work.
                            OOPSSSS.... its working... working when i use Proxy.NO_PROXY. .. Thanks man.

                            fREDDIE

                            Comment

                            • freddieMaize
                              New Member
                              • Aug 2008
                              • 85

                              #15
                              Originally posted by freddieMaize
                              I initially tried with no proxy also, but then it dint work.
                              OOPSSSS.... its working... working when i use Proxy.NO_PROXY. .. Thanks man.
                              Originally posted by r035198x
                              ...without setting any System properties...
                              By the way, any simple reason or explanation for why it was not working with System properties and why it was working with Proxy.NO_PROXY. Just to know i'm asking

                              fREDDIE

                              sorry for the typo

                              Comment

                              Working...