我试图连接到主机。错误"连接重置"总是出现在websphere中。 作为一个没有websphere的自编写Java项目,它使用相同的代码。该 错误不会发生。我怀疑websphere和ciphersuite" TLS ... SHA386"别'吨 一起工作。但是在设置套接字时不会发生错误。有人能帮助我吗?
我合作: websphere v8.5.5.11 java-sdk 1.8.64_bundled
这里是我的Java代码:
@Singleton
@Startup
public class ClientStart {
@PostConstruct
public void startClient(){
try {
testHttp();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
void testHttp() throws Exception {
String token24h = "eyJhbGci ... 95BBo7PVej8uXdw9sA";
String url = "https:// ... /apserver/api/products/111234568408/packs/U1Q0MUFHUEdHMExXQUo=?ctx=f2a98d0d-9d06-45e3-8f58-87f9d3cfcb06&lot=QlRFNEdBTQ==&exp=310822&pcs=PPN&sid=07758c03-d265-454d-8544-6d0e2ca29d53";
URL obj = new URL(url);
HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();
SSLSocketFactory socketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
SSLSocket sslsocket = (SSLSocket) SSLSocketFactory.getDefault().createSocket();
sslsocket.setEnabledCipherSuites(new String[]{
"TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384"
});
con.setSSLSocketFactory(socketFactory);
//create Request-Header aufbauen
con.setRequestMethod("GET");
con.setRequestProperty(HttpHeaders.AUTHORIZATION, "Bearer " + token24h);
con.setRequestProperty(HttpHeaders.CACHE_CONTROL,"no-cache");
con.setRequestProperty(HttpHeaders.ACCEPT,"application/json");
con.setRequestProperty(HttpHeaders.ACCEPT_ENCODING,"application/json");
int responseCode = con.getResponseCode();
//TODO other things
}
步骤con.getResponseCode()出现此Stacktrace
[31.03.18 16:49:09:269 CEST] 00000054 SystemErr R java.net.SocketException:Connection reset [31.03.18 16:49:09:269 CEST] 00000054在java.net.SocketInputStream.read上的SystemErr R(SocketInputStream.java:220) [31.03.18 16:49:09:285 CEST] 00000054 java.net.SocketInputStream.read中的SystemErr R(SocketInputStream.java:152) [31.03.18 16:49:09:285 CEST] 00000054 SystemErr R at com.ibm.jsse2.a.a(a.java:79) [31.03.18 16:49:09:285 CEST] 00000054 SystemErr R at com.ibm.jsse2.a.a(a.java:182)
请帮帮我。感谢。