0

我正在使用 httpclient-3.0 库将数据解析到云端。当我在本地机器(Windows 10)上运行应用程序时,它工作正常,数据被解析到服务器并且我收到成功响应,但是当我将它部署到在 Windows server 2012 R2 上运行的服务器上时,它会在下面抛出错误。我也使用了相同的 JDK,我尝试了很多方法,例如在我的 java.security jdk 文件中添加 -Djdk.tls.client.protocols="TLSv1,TLSv1.1,TLSv1.2" ,但问题仍然没有解决。

这是我的代码

PostMethod post = new PostMethod(apiUrl);
post.setParameter("authtoken", authToken);
post.setParameter("dateFormat", dateTimeFormat);
post.setParameter("data", emloyeesAttendanceJsonArr.toString());
HttpClient httpclient = new HttpClient();
// Configuring proxy
httpclient.getHostConfiguration().setProxy("**.**.**.**", ****);
try {
    long timeTrace = System.currentTimeMillis();
    int result = httpclient.executeMethod(post);
    System.out.println(">> HTTP Response status code: "+result);
    System.out.println(">> Response Time: "+(System.currentTimeMillis() - timeTrace));
.......
.......
.......
}

我感谢任何快速的帮助和指导。

这是我得到的错误

Mar 11, 2020 4:23:08 PM org.apache.commons.httpclient.HttpMethodDirector execute
WithRetry
INFO: I/O exception (javax.net.ssl.SSLProtocolException) caught when processing
request: Connection reset
Mar 11, 2020 4:23:08 PM org.apache.commons.httpclient.HttpMethodDirector execute
WithRetry
INFO: Retrying request
Mar 11, 2020 4:23:23 PM org.apache.commons.httpclient.HttpMethodDirector execute
WithRetry
INFO: I/O exception (javax.net.ssl.SSLProtocolException) caught when processing
request: Connection reset
Mar 11, 2020 4:23:23 PM org.apache.commons.httpclient.HttpMethodDirector execute
WithRetry
INFO: Retrying request
Mar 11, 2020 4:23:38 PM org.apache.commons.httpclient.HttpMethodDirector execute
WithRetry
INFO: I/O exception (javax.net.ssl.SSLProtocolException) caught when processing
request: Connection reset
Mar 11, 2020 4:23:38 PM org.apache.commons.httpclient.HttpMethodDirector execute
WithRetry
INFO: Retrying request
javax.net.ssl.SSLProtocolException: Connection reset
        at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:126)
        at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.ja
va:321)
        at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.ja
va:264)
        at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.ja
va:259)
        at java.base/sun.security.ssl.SSLTransport.decode(SSLTransport.java:137)

        at java.base/sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:11
52)
        at java.base/sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocke
tImpl.java:1063)
        at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl
.java:402)
        at java.base/sun.security.ssl.SSLSocketImpl.ensureNegotiated(SSLSocketIm
pl.java:716)
        at java.base/sun.security.ssl.SSLSocketImpl$AppOutputStream.write(SSLSoc
ketImpl.java:970)
        at java.base/java.io.BufferedOutputStream.flushBuffer(BufferedOutputStre
am.java:81)
        at java.base/java.io.BufferedOutputStream.flush(BufferedOutputStream.jav
a:142)
        at java.base/java.io.FilterOutputStream.flush(FilterOutputStream.java:15
3)
        at org.apache.commons.httpclient.methods.EntityEnclosingMethod.writeRequ
estBody(EntityEnclosingMethod.java:502)
        at org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodB
ase.java:1973)
        at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.j
ava:993)
        at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(Htt
pMethodDirector.java:397)
        at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMe
thodDirector.java:170)
        at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.jav
a:396)
        at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.jav
a:324)
        at af.aib.etl.AttendanceETL.fetchAndParseAttendanceRecord(AttendanceETL.
java:99)
        at af.aib.attendance.ApplicationStartPoint.main(ApplicationStartPoint.ja
va:28)
Caused by: java.net.SocketException: Connection reset
        at java.base/java.net.SocketInputStream.read(SocketInputStream.java:186)

        at java.base/java.net.SocketInputStream.read(SocketInputStream.java:140)

        at java.base/sun.security.ssl.SSLSocketInputRecord.read(SSLSocketInputRe
cord.java:448)
        at java.base/sun.security.ssl.SSLSocketInputRecord.decode(SSLSocketInput
Record.java:165)
        at java.base/sun.security.ssl.SSLTransport.decode(SSLTransport.java:108)
4

1 回答 1

0

本地代理和服务器代理不同,这就是为什么它在我的本地计算机上运行良好但在服务器上运行良好的原因,一旦我将代理更改为服务器正在使用的特定代理,那么应用程序运行正常。

于 2020-06-28T09:52:52.800 回答