• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Server returned HTTP response code: 504 for URL...

 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My websbite (Apache) uses private IP address and is publihsed by a Microsoft ISA proxy server. Public Internet users can access the website through the proxy server.

On my website, it uses applet to send date to servlet (they are on the same computer), then servlet searches data according to the date from applet and send the data back to applet. When the date is less than one day long, it works well, when the date is more than one day, it shows the following error:

java.io.IOException: Server returned HTTP response code: 504 for URL:http://11.11.11.11:8080/myservlet/servlet/...'

The servlet and applet use ObjectInputStream and ObjectOutputStream to communication with each other.

I check the error code, it is said:
Status code (504) indicating that the server did not receive a timely response from the upstream server while acting as a gateway or proxy.

But I still don't understand the error clearly, and how to solve the problem? Thanks for any suggestion!
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My guess (without seeing the servlet code) is that there is a bug in the servlet causing it to go into an infinite loop under the conditions you see. Try moving the code to a stand-alone class and testing it outside the servlet container, or attaching a debugger to your servlet to trace the behaviour.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
On a side note, it looks like you're using the 'Invoker Servlet' to access your servlets. This is generally frowned on since it can cause security and general application problems. The preferred way to access servlets is to disable the invoker servlet and provide the correct servlet configuration in the web.xml file.

Just in case you're wondering what I mean, the path /[context]/servlet/... hints that the invoker servlet is being used.

Dave
[ September 18, 2005: Message edited by: David O'Meara ]
 
may Lee
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I did a test with my program without passing throguh the proxy server, I mean all
are on the private network, the webserver only on the private LAN and I access the website from LAN, there is no any map between private and public IP address for applet CODEBASE and servlet path, then it works well even for long time period, eg 5 days. SO I guess, it may be some timeout problem on the ISA proxy server when the mapping between private and public IP address is timeout.

Because when users ask data of long time period, say more than one day, the servlet takes at least more than 6-7 minutes to get all the data on the LAN, if asking for 5 days' data, it will take maybe 20 minutes to get the data, so maybe the mapping on ISA proxy server or the HTTP connection between servlet and applet cannot exist so long?

I am still looking for solutions. Any suggestion is appreciated. Thanks a lot.
 
may Lee
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is part of my code in applet and servlet, not complete of course:

(1) Part code of applet

/*In the applet code, I define the servlet path like this*/
String servletPath="http://192.168.0.24/myservlet/servlet/servletToapplet";

/* This is part of the applet code to send date to servlet*/
try{
URL url=new URL(servletPath);
URLConnection conn=url.openConnection();
conn.setDoInput(true);
conn.setDoOutput(true);
conn.setUseCaches(false);
conn.setDefaultUseCaches(false);
/****send object from applet to servlet******************/
conn.setRequestProperty("Content-Type","application/octet-stream");
ObjectOutputStream toServlet=new ObjectOutputStream(conn.getOutputStream());
toServlet.writeObject(datato);
toServlet.flush();
toServlet.close();
/****get object df from servlet*********/
ObjectInputStream fromServlet=new ObjectInputStream(conn.getInputStream());
datafrom=(dataFromservlet)fromServlet.readObject();
fileexist=datafrom.fileexist;
servleterror=datafrom.servleterror;

}

(2)
/* This is part of servlet code, to show how servlet get date from applet and*/

try{
/****servlet gets input stream from applet***********************/
fromApplet=new ObjectInputStream(request.getInputStream());
/**read the serialized object (dataToservlet) from applet**/
dt=(dataToservlet) fromApplet.readObject();
fromApplet.close();
....


(3)
/*this is part of the servlet code to show how servlet send data back to applet by object*/
response.setContentType("java-internal/"+dataFromservlet.class.getName());
toApplet=new ObjectOutputStream(response.getOutputStream());
toApplet.writeObject(df);
toApplet.flush();
toApplet.close();
 
may Lee
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not clear what to do with the invoker. The following is my web.xml for the servlet under Tomcat. How to change? Could you show me?

<?xml version="1.0" encoding="ISO-8859-1"?>



<!DOCTYPE web-app

PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"

"http://java.sun.com/dtd/web-app_2_3.dtd">



<web-app>


<servlet>
<servlet-name>servletToapplet</servlet-name>
<servlet-class>servletToapplet</servlet-class>
</servlet>


<servlet-mapping>

<servlet-name>invoker</servlet-name>

<url-pattern>/servlet/*</url-pattern>

</servlet-mapping>



<servlet-mapping>
<servlet-name>servletToapplet</servlet-name>
<url-pattern>/servletToapplet</url-pattern>
</servlet-mapping>


</web-app>
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As Ben is fold (and correct) of saying, you should see this:
http://faq.javaranch.com/view?InvokerServlet
 
may Lee
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I found the solution for my problem. Share it here, hope it can give people some idea when they meet similar problems.

The error is because of the CODEBASE and servletPath. I am using proxy server to publish my website. Before I used private IP addresse for the CODEBASE and servletPath. So I changed them to the public IP address and make map of the public and private IP address on the proxy server. Now it is working.
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, May Lee for sharing the solution. Congrats you got it work.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic