469,338 Members | 8,112 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,338 developers. It's quick & easy.

504 error

freddieMaize
Hi all,

I used the below,
Expand|Select|Wrap|Line Numbers
  1. InputStream in = new URL ("http://127.0.0.1/search?q=travel") .openStream () ; 
I'm getting the below,
[HTML]java.io.IOException: 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??
Nov 18 '08 #1
17 6405
JosAH
11,448 Expert 8TB
Do you have a web server or servlet container etc. running on your local host on
your default port (80)?

kind regards,

Jos
Nov 18 '08 #2
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
Nov 18 '08 #3
JosAH
11,448 Expert 8TB
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
Nov 18 '08 #4
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,

Expand|Select|Wrap|Line Numbers
  1. 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
Nov 19 '08 #5
r035198x
13,262 8TB
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.
Nov 19 '08 #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.
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
Nov 19 '08 #7
r035198x
13,262 8TB
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?
Nov 19 '08 #8
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.
Nov 19 '08 #9
r035198x
13,262 8TB
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).getInputStream();
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.
Nov 19 '08 #10
Just trying to eliminate another doubt with your proxy ...

Instead of openStream(), try using openConnection(aProxy).getInputStream();
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,

Expand|Select|Wrap|Line Numbers
  1. System.getProperties().put("proxySet", "true");
  2.     System.getProperties().put("proxyHost", "proxy");
  3.     System.getProperties().put("proxyPort", "80"); 
  4.  
  5.         URL yahoo = new URL("http://172.16.1.21/search?q=travel");
  6.         URLConnection yc = yahoo.openConnection();
  7.         BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
I'm wondering why this 504 is comming.

fREDDIE
Nov 19 '08 #11
r035198x
13,262 8TB
Try setting the proxy like I suggested without setting any System properties. See my post above again.
Nov 19 '08 #12
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?

Expand|Select|Wrap|Line Numbers
  1. SocketAddress addr = new InetSocketAddress("myProxy", 80);
  2.     Proxy proxy = new Proxy(Proxy.Type.HTTP, addr);
  3.  
  4.     URL url = new URL("http://ServerMachine/search?q=travel");
  5.     URLConnection yc = url.openConnection(proxy);
  6.     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
Nov 20 '08 #13
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
Nov 20 '08 #14
I initially tried with no proxy also, but then it dint work.
OOPSSSS.... its working... working when i use Proxy.NO_PROXY... Thanks man.
...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
Nov 20 '08 #15
r035198x
13,262 8TB
..
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
I am actually curious as to why you thought what you did with the System properties works.
Nov 20 '08 #16
I am actually curious as to why you thought what you did with the System properties works.
The same curiosity was there with me also :). I'm not using my PC. Hence I didnít know the LAN settings (unfortunately missed). And to access the 'ServerMachine' no internet proxy is needed it seems. So the ip of the 'ServerMachine' was listed in the "Do not use proxy for..." list in the internet options.

So why initialy i went for System.properties.

fREDDIE
Nov 20 '08 #17
r035198x
13,262 8TB
Why did you think that openConnection looks for a System property called "proxy"? Also, if you read the API specs for the System class you will see that "proxy" is not a property guaranteed to be always available.
Nov 21 '08 #18

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Gregory | last post: by
7 posts views Thread by p | last post: by
3 posts views Thread by Manuel | last post: by
1 post views Thread by developer | last post: by
reply views Thread by mchuc7719 | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by Marylou17 | last post: by
1 post views Thread by Marylou17 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.