`
aerchi
  • 浏览: 427173 次
  • 性别: Icon_minigender_1
  • 来自: 昆明
文章分类
社区版块
存档分类
最新评论

java.net.SocketException: Malformed reply from SOCKS server

 
阅读更多


当IE设置有SOCKS(套接字)代理时,NetBeans Java Desktop Application也就是GUI窗口程序连接数据库总是会失败。如果关闭代理的设置,程序则能正常运行。

程序表现为:长时间处于连接状态而不返回。监视TCP连接,发现程序长时间连接到代理的IP上。

大约5分钟后,连接被断开,返回如下异常:
2012-05-05 13:16:15,984 ERROR [101001003] (WorkerThread.java:73) - com.microsoft.sqlserver.jdbc.SQLServerException: 到主机 的 TCP/IP 连接失败。 java.net.SocketException: Malformed reply from SOCKS server

这个问题肯定与IE代理有关,但System.getProperty()对"http.proxyHost"、"htttps.proxyHost"、"socksProxyHost"得到的结果都是null。

于是跟踪DriverManager.getConnection()代码到 class java.net.SocksSocketImpl 的 protected void connect(SocketAddress endpoint, int timeout) 方法中,看到如下调用:
ProxySelector.getDefault();

根据 ProxySelector.getDefault() 和 java 两个关键字google找到一篇资料:


Java Database Connectivity (JDBC) - JDBC Microsoft SQL Problem

得知问题的原因在于 NetBeans Swing Application Framework 的 org.jdesktop.application.Application.create() 调用了
System.setProperty("java.net.useSystemProxies", "true");
其中提出了两种解决办法:
public void main(String[] args) {
ProxySelector.getDefault();
// code
}
或者
@Override
protected void startup() {
invoke System.setProperty("java.net.useSystemProxies", "false");
// code
}

其它参考
Java Networking and Proxies


===========================================================================================================


Hi, I got RSEG1243 error when conecting from RDz v801 client. The host version is also 801


My another PC works fine. So I guess the host setup should be correct. Any idea for the error? Great thanks for help!

java.net.SocketException: Malformed reply from SOCKS server
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 java.net.Socket.connect(Unknown Source)

at java.net.Socket.<init>(Unknown Source)

at java.net.Socket.<init>(Unknown Source)

at org.eclipse.dstore.core.client.ClientConnection.connectDaemon(Unknown Source)

at com.ibm.etools.zseries.util.DStoreWithSSHConnectorService.launchServer(Unknown Source)

at com.ibm.etools.zseries.util.DStoreWithSSHConnectorService.launchServer(Unknown Source)

at org.eclipse.rse.connectorservice.dstore.DStoreConnectorService.connectWithDaemon(Unknown Source)

at org.eclipse.rse.connectorservice.dstore.DStoreConnectorService.internalConnect(Unknown Source)

at org.eclipse.rse.core.subsystems.AbstractConnectorService$1.run(Unknown Source)

at org.eclipse.rse.core.subsystems.AbstractConnectorService$SafeRunner.run(Unknown Source)

at org.eclipse.rse.core.subsystems.AbstractConnectorService.connect(Unknown Source)

at org.eclipse.rse.core.subsystems.SubSystem.connect(Unknown Source)

at org.eclipse.rse.internal.ui.actions.SystemConnectAllSubSystemsAction$ConnectAllJob.run(Unknown Source)

at org.eclipse.core.internal.jobs.Worker.run(Unknown Source)


A suggestion given by our server side expert...

Can you check to see if the PC w/ the connectivity issue have the same SOCKS server and the same JDK level as the other one that can connect?

Steven

-------------------

Hi, Thanks for the idea, this is exactly the problem!

We found the "SOCKS" box is checked in the Perference --> Network Connection. And this setting is imported from client PC's IE setup automatically.

We change the IE setup to uncheck the SOCKS option and it works now.

Also we found in RDz v7.1 it won't import IE setup automatically, so the problem is not exist in v7.1 client.





分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics