Quantcast
Channel: sshnet Discussions Rss Feed
Viewing all articles
Browse latest Browse all 1729

New Post: Port Forwarding and Java application launch

$
0
0
Hello all, first of all thank you for this great community, I am learning a lot as I go. I am by no means a programmer by trade, I write code with a means to and end approach, and so any solution I came to is usually far from elegant. I also do not know much about the various ways to debug but I will try to pull together as much information for those willing to help as I can. Also, I apologize for any incorrect use of jargon.

The problem I am having is with, as the title suggests, Port Forwarding and launching a Java application. I am able to successfully create an ssh tunnel to my server with the following code.
                        pubfile = new PrivateKeyFile("C:\\System Apps\\" + _SSHkeyfile, _SSHpassword);
                        sshclient = new SshClient(_HostURI, _SSHPort, _SSHusername, pubfile);
                        sshclient.Connect();
                        forport1 = new ForwardedPortLocal("127.0.0.1", 65088, "127.0.0.1", 8088);
                        forport2 = new ForwardedPortLocal("localhost", 65088, "localhost", 8088);
                        sshclient.AddForwardedPort(forport1);
                        sshclient.AddForwardedPort(forport2);
                        System.Threading.Thread.Sleep(1000 * 1);
                        forport1.Exception +=new EventHandler<ExceptionEventArgs>(forport1_Exception);
                        forport1.Start();
                        forport2.Start();
I know it's working because the server hosts a webpage at 127.0.0.1:65088, and I am able to load firefox and navigate to said page and click through any number of links that reside on the page. However whenever I try to launch a Java application, the application is able to download to my local computer but when the application runs I receive the following error.

System.Net.Sockets.SocketException (0x80004005): An existing connection was forcibly closed by the remote host
at Renci.SshNet.Session.WaitOnHandle(WaitHandle waitHandle)
at Renci.SshNet.Channels.Channel.Close(Boolean wait)
at Renci.SshNet.Channels.ChannelDirectTcpip.Close()
at Renci.SshNet.ForwardedPortLocal.<>c__DisplayClass3.<InternalStart>b__2()

from the ForwardedPortLocal ExceptionEventArgs and this error

System.Net.Sockets.SocketException (0x80004005): An existing connection was forcibly closed by the remote host
at System.Net.Sockets.Socket.Send(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at Renci.SshNet.Channels.ChannelDirectTcpip.InternalSocketSend(Byte[] data)
at System.EventHandler`1.Invoke(Object sender, TEventArgs e)
at Renci.SshNet.Session.MessageListener()

from the SshClient ExceptionEventArgs.

What's interesting is that I was able to load the java application 1 time, and every time since then I get a "Connection Refused" as reported by the Java application.

I am able to use Putty to connect and load the Java application with no problems.

Any and all help is much appreciated, thanks!

Viewing all articles
Browse latest Browse all 1729

Trending Articles