commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dean <dean.w.parsh...@gmail.com>
Subject Telnet Client connection timeout
Date Fri, 08 Oct 2010 16:58:49 GMT
Hello,

I am writing an app that connects to a server via telnet and scrapes
some data. I am having issues with the initial connection. All i get are
timout exceptions:

java.net.ConnectException: Connection timed out
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
        at
java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
        at java.net.Socket.connect(Socket.java:529)
        at
org.apache.commons.net.SocketClient.connect(SocketClient.java:176)
        at
org.lightspeedtech.ProductionAssistant.TelnetHandler.connect(TelnetHandler.java:104)

here is the relevant code:

TelnetHandler(Data data){
	this.data = data;
	tnet = new TelnetClient();
	ttopt = new TerminalTypeOptionHandler("VT100", false, false, true,
false);
     echoopt = new EchoOptionHandler(true, false, true, false);
     gaopt = new SuppressGAOptionHandler(true, true, true, true);
	try
        {
            tnet.addOptionHandler(ttopt);
            tnet.addOptionHandler(echoopt);
            tnet.addOptionHandler(gaopt);
        }
        catch (InvalidTelnetOptionException e)
        {
            System.err.println("Error registering option handlers: " +
e.getMessage());
        }

}

protected boolean connect(){
	try {
	System.out.println("Trying to connect");

	// throws timout exception
	tnet.connect(SPO_SERVER, 23);


	in = tnet.getInputStream();
	out = (PrintStream)tnet.getOutputStream();
	System.out.println("Connecting to server..");
	readUntil(LOGIN_PROMPT);
	write(data.telnetUserName);
	System.out.println("Sending username..");
	readUntil(PASS_PROMPT);
	System.out.println("Sending pass..");
	write(data.telnetUserName);
	readUntil(SHELL_PROMPT);
	System.out.println("got shell..");
	write(SELECT_MENU);
	readUntil(SUP_MAIN_PROMPT);
	System.out.println("got sup menu..");

	return true;
	}
	catch( Exception e){
		e.printStackTrace();
		return false;

	}
}

The server is firewalled, requiring a connect via web browser or telnet
once to allow. I can connect fine via a linux telnet, but not via my
app. Any ideas would be appreciated.

Thanks,

~Dean Parshall



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message