HttpMethodDirectory executeWithRetry и SSLProtocolException в Java - PullRequest
0 голосов
/ 11 марта 2020

Я использую библиотеку httpclient-3.0 для анализа данных в облаке. Когда я запускаю приложение на своем локальном компьютере (Windows 10), оно работает нормально, и данные анализируются на сервере, и я получаю ответ об успешном выполнении, но когда я развернул его на нашем сервере, который работает на Windows server 2012 R2 Кидает ниже ошибки. Я использовал тот же JDK, что и я, пытался разными способами, например, добавлять -Djdk.tls.client.protocols = "TLSv1, TLSv1.1, TLSv1.2" в мой файл java .security jdk, но проблема все еще не в этом решен.

Вот мой код

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)
...