Wow! What a quick response. Thank you for your information. -Peter
-----Original Message----- From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]] Sent: Saturday, July 27, 2002 3:41 PM To: Tomcat Developers List Subject: Re: tomcat 4.0 remote shutdown question ... On Sat, 27 Jul 2002, HAVENS,PETER (HP-Cupertino,ex3) wrote: > Date: Sat, 27 Jul 2002 18:35:23 -0400 > From: "HAVENS,PETER (HP-Cupertino,ex3)" <[EMAIL PROTECTED]> > Reply-To: Tomcat Developers List <[EMAIL PROTECTED]> > To: "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]> > Subject: tomcat 4.0 remote shutdown question ... > > I have found that I cannot connect to the tomcat shutdown port remotely. > Using code highly leveraged from the tomcat source, I wrote a simple java > app to issue the shutdown command to a given server and port #. It only > seems to work if I use "localhost" as the server name. If I try to use the > hostname or the fully qualified host name (even of the local system) it will > fail. I have tried using this to stop Tomcat on linux and Windows XP with > the same results. I have included the output I get when I run it and the > source code. Any help understanding this would be greatly appreciated. > Tomcat deliberately accepts connections to the shutdown port only from localhost as a security precaution. After all, you really don't want anyone on the Internet to be able to shut down your Tomcat instance. To change this behavior, you'd need to change the Tomcat source code for the logic that opens the shutdown port's socket. It's not configurable. Craig > -------------------------Sample output-------------------------------- > Attempting to shut down the tomcat server on ovwpc574/15.27.245.212 using > port 8085 > > tomcat_stop: java.net.ConnectException: Connection refused > java.net.ConnectException: Connection refused > at java.net.PlainSocketImpl.socketConnect(Native Method) > at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:295) > at > java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:161) > at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:148) > at java.net.Socket.connect(Socket.java:425) > at java.net.Socket.connect(Socket.java:375) > at java.net.Socket.<init>(Socket.java:290) > at java.net.Socket.<init>(Socket.java:146) > at tomcat_stop.main(tomcat_stop.java:40) > -------------------------End of Sample > output-------------------------------- > > -------------------------Source Code-------------------------------- > import java.io.*; > import java.io.IOException; > import java.net.Socket; > import java.net.InetAddress; > > > class tomcat_stop > { > > public static void main( String [] args ) > { > int port_number; > InetAddress server_address=null; > Socket socket; > > if (args.length != 2) > usage(); > > port_number = Integer.parseInt(args[1]); > > try > { > server_address = > InetAddress.getByName(args[0]); > } > catch (IOException e) > { > System.out.println(""); > System.out.println("Unable to get > InetAddress using getByName on " + > args[0]); > System.out.println(":tomcat_stop " + e); > e.printStackTrace(System.out); > System.exit(1); > } > > // Stop the existing server > try { > System.out.println("\n\nAttempting to > shut down the tomcat server on " + > server_address + " using > port " + port_number + "\n\n"); > > socket = new Socket(server_address, > port_number); > OutputStream stream = > socket.getOutputStream(); > String shutdown = "SHUTDOWN"; > for (int i = 0; i < shutdown.length(); > i++) > > stream.write(shutdown.charAt(i)); > stream.flush(); > stream.close(); > socket.close(); > } > catch (IOException e) > { > System.out.println("tomcat_stop: " + e); > e.printStackTrace(System.out); > System.exit(1); > } > } > > public static void usage() > { > System.out.println("\nUsage:\n\ttomcat_stop <system > name> <port>\n\n"); > System.exit(1); > } > } > > > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>