本文介绍了java.net.SocketException:来自SOCKS服务器的格式错误的回复,使用apache FTPClient的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正尝试在Java web start应用程序中使用Apache FTPCleint连接到FTP服务器。
下面是我使用的代码。

  ftpInstance = new FTPClient(); 

ftpInstance.setRemoteVerificationEnabled(false);

ftpInstance.connect(< HostName>);
int rpyCode = ftpInstance.getReplyCode();

if(!FTPReply.isPositiveCompletion(rpyCode)){
抛出新异常(Connection Rejected with reply code+ rpyCode +。 - +< Hostname>);
}

问题出现在 ftpInstance.connect(<主机名>)。抛出异常请看堆栈跟踪

  java.lang.RuntimeException:java.net.SocketException:格式错误的回复SOCKS服务器
在com.newgen.backend.Operation.call(Operation.java:91)
在filetransfermanager.FileTransferManagerView $ 1.windowOpened(FileTransferManagerView.java:48)
在java.awt。 AWTEventMulticaster.windowOpened(未知源)
在java.awt.Window.processWindowEvent(未知源)
在javax.swing.JFrame.processWindowEvent(未知源)
在java.awt.Window。 processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(未知源)
在java.awt.Component.dispatchEvent(未知源)
在java.awt.EventQueue.dispatchEventImpl(未知源)
在java.awt.EventQueue.access $ 000(未知源)
在java.awt.EventQueue $ 1.run(未知源)
在java.awt.Even tQueue $ 1.run(未知源)$ java.util.AccessController.doPrivileged(Native方法)
在java.security.AccessControlContext处
$ 1.doIntersectionPrivilege(未知源)$ java.util中的
。 AccessControlContext $ 1.doIntersectionPrivilege(未知源)$ b $在java.awt.EventQueue $ 2.run(未知源)$ b $在java.awt.EventQueue $ 2.run(未知源)$ b $在java.security .AccessController.doPrivileged(Native Method)$ java.util.AccessControlContext中的b $ b $ 1.doIntersectionPrivilege(未知源)$ b $ at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt。 EventDispatchThread.pumpOneEventForFilters(未知源)
在java.awt.EventDispatchThread.pumpEventsForFilter(未知源)
在java.awt.EventDispatchThread.pumpEventsForHierarchy(未知源)
在java.awt.EventDispatchThread。 pumpEvents(未知源)
在java.awt.EventDispatchThread.pumpEvents(未知源)$ b $在java.awt.EventDispatchThread.run(未知源)

Cau sed来自:java.net.SocketException:来自SOCKS服务器的格式错误的回复$ java
在java.net.SocksSocketImpl.readSocksReply(未知源)
在java.net.SocksSocketImpl.connect(未知源)
在java.net.Socket.connect(未知源)
在org.apache.commons.net.SocketClient.connect(SocketClient.java:171)
在org.apache.commons.net.SocketClient。连接(SocketClient.java:192)
在org.apache.commons.net.SocketClient.connect(SocketClient.java:285)
在com.newgen.ftp.FTPInstance.getInstance(FTPInstance.java: 38)
at com.newgen.backend.Transport。< init>(Transport.java:58)
at com.newgen.backend.Operation.call(Operation.java:81)
... 27 more

以上代码在正常项目中工作正常,但不在java web start中。



任何帮助表示赞赏。
Thanks。

解决方案

您已配置指向非SOCKS代理的SOCKS代理设置。 / p>

I am trying to connect to FTP Server using Apache FTPCleint in java web start aplication.Below is the code i am using.

ftpInstance = new FTPClient();

ftpInstance.setRemoteVerificationEnabled(false);

ftpInstance.connect(<HostName>);
int rpyCode = ftpInstance.getReplyCode();

if(!FTPReply.isPositiveCompletion(rpyCode)){
    throw new Exception("Connection Rejected with reply code " + rpyCode + ". - " + <Hostname>);
}

Problem is at line ftpInstance.connect(<HostName>). An exception is been thrown Please look at the stack trace

java.lang.RuntimeException: java.net.SocketException: Malformed reply from SOCKS server
at com.newgen.backend.Operation.call(Operation.java:91)
at filetransfermanager.FileTransferManagerView$1.windowOpened(FileTransferManagerView.java:48)
at java.awt.AWTEventMulticaster.windowOpened(Unknown Source)
at java.awt.Window.processWindowEvent(Unknown Source)
at javax.swing.JFrame.processWindowEvent(Unknown Source)
at java.awt.Window.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

Caused by: java.net.SocketException: Malformed reply from SOCKS server
at java.net.SocksSocketImpl.readSocksReply(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at org.apache.commons.net.SocketClient.connect(SocketClient.java:171)
at org.apache.commons.net.SocketClient.connect(SocketClient.java:192)
at org.apache.commons.net.SocketClient.connect(SocketClient.java:285)
at com.newgen.ftp.FTPInstance.getInstance(FTPInstance.java:38)
at com.newgen.backend.Transport.<init>(Transport.java:58)
at com.newgen.backend.Operation.call(Operation.java:81)
... 27 more

Above code is working fine in normal project but not in java web start.

Any help is appreciated.Thanks.

解决方案

You have configured SOCKS proxy settings that point to something that isn't a SOCKS proxy.

这篇关于java.net.SocketException:来自SOCKS服务器的格式错误的回复,使用apache FTPClient的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 10:52