javax.net.ssl.SSLException的随机出现:无法识别的ssl消息,纯文本连接?

javax.net.ssl.SSLException的随机出现:无法识别的ssl消息,纯文本连接?,java,ssl,https,Java,Ssl,Https,在执行java代码的过程中,我收到了这个错误消息 Exception in thread "main" AxisFault faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException faultSubcode: faultString: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection? faultAc

在执行java代码的过程中,我收到了这个错误消息

Exception in thread "main" AxisFault  faultCode:
{http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:   faultString: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
faultActor:   faultNode:
faultDetail: 
{http://xml.apache.org/axis/}stackTrace: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?    at
com.sun.net.ssl.internal.ssl.InputRecord.handleUnknownRecord(InputRecord.java:523) at
 com.sun.net.ssl.internal.ssl.InputRecord.read(InputRecord.java:355) at
com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:830)   at
com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1170) at
com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1197)  at
com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1181)  at
org.apache.axis.components.net.JSSESocketFactory.create(JSSESocketFactory.java:186) at
org.apache.axis.transport.http.HTTPSender.getSocket(HTTPSender.java:191)    at
org.apache.axis.transport.http.HTTPSender.writeToSocket(HTTPSender.java:404)    at
org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:138) at
org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32) at
org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)    at
org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)     at
org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)   at
org.apache.axis.client.Call.invokeEngine(Call.java:2765)    at
org.apache.axis.client.Call.invoke(Call.java:2748)  at
org.apache.axis.client.Call.invoke(Call.java:2424)  at
org.apache.axis.client.Call.invoke(Call.java:2347)  at
org.apache.axis.client.Call.invoke(Call.java:1804)  at
crmondemand.ws.ecbs.customobject5.CustomObject5_BindingStub.customObject5Update(CustomObject5_BindingStub.java:301) at
crm.sapGUID.urlupdate(sapGUID.java:170)     at
 crm.sapGUID.readExcelFile(sapGUID.java:102)    at
 crm.sapGUID.main(sapGUID.java:218)
每次我重新运行程序时都会随机出现此错误。有时在10分钟之后,有时在8分钟之后,sumtime在1分钟之后,甚至在15分钟之后

我支持代理,并在JAVA中硬编码了与Internet Explorer中相同的代理设置

System.setProperty("https.proxyHost", "172.*.*.*");
System.setProperty("https.proxyPort", "8003");
System.setProperty("javax.net.ssl.trustStore", "/Oracle/Middleware/wlserver_10.3/server/lib/cacerts");

我认为这是因为您使用的是
System.setProperty()
。。。如果同一JVM中的其他东西正在调用同一个System.setProperty(),它将覆盖您的设置。在这里,您最好使用:

InetSocketAddress proxyInet = new InetSocketAddress("172...*",8003);
Proxy proxy = new Proxy(Proxy.Type.HTTP, proxyInet);

javax.net.ssl.trustStore
可能还可以,因为它是通过命令行中的-D选项传入的,很少更改,所以我认为不需要在代码中设置它。至少如果您需要它,请在
静态{}
块中设置它,这样它将只加载一个,无需重复设置。

除非您总是使用相同的URL运行此程序,否则您所做的正是它在例外情况下所说的:使用SSL连接到纯文本端口。偶尔。

设置环境变量

_JAVA_OPTIONS = -Djava.net.preferIPv4Stack=true
这解决了我的问题。如果你在公司的专用网络上,试试看