我们正在尝试实现一个http2码头客户端,该客户端与我们的远程服务器进行多路复用连接。我们的程序如下
Security.addProvider(new OpenSSLProvider());//Conscrypt for ALPN support in jdk8
SslContextFactory sslContextFactory = new SslContextFactory.Client(true);
sslContextFactory.setProvider("Conscrypt");
sslContextFactory.setProtocol("TLSv1.3");//Use TLSv1.3
HTTP2Client http2Client = new HTTP2Client();
http2Client.setConnectTimeout(5000);
http2Client.setIdleTimeout(30000);
org.eclipse.jetty.client.HttpClient http2HttpClient = new org.eclipse.jetty.client.HttpClient(new HttpClientTransportOverHTTP2(http2Client), sslContextFactory);
http2HttpClient.setConnectTimeout(5000);
http2HttpClient.setIdleTimeout(30000);
http2HttpClient.start();
http2HttpClient.addBean(sslContextFactory);
http2HttpClient.start();
org.eclipse.jetty.client.api.Request request = http2HttpClient.POST(locationurl+locationposturl);
request.header(HttpHeader.CONTENT_TYPE, "application/json");//No I18N
request.header("Pragma", "no-cache");
request.header("Custom", customheaderName);
request.header("Secure", secureHeader);
request.header("protocol", "h2");
request.content(new StringContentProvider(myXMLRequest,"utf-8"));
request.timeout(420, TimeUnit.SECONDS);
request.idleTimeout(30, TimeUnit.SECONDS);
ContentResponse response = request.send();
if (response != null && (response.getStatus() >= 200 && response.getStatus() < 400)) {
int statuscode=response.getStatus();
byte [] wbresponse = response.getContent();
}
我们使用同步调用和conscrypt(安全提供程序)在jdk8中支持ALPN并使用TLSv1.3。我们能够成功向我们的远程位置发出http2请求。但是我们面临一个问题,即大多数线程无限期地挂起,直到重新启动服务器。我们在两端都使用tomcat 9.x,每个远程服务器都位于专用的HAproxy(用作h2 / ssl终结器)的后面。
客户: 使用的安全提供程序: Conscrypt-2.1.0 ,JAVA: JDK 8 ,tomcat: 9.0.21 ,码头: 9.4.19
服务器: JAVA: JDK 11 ,tomcat: 9.0.21 ,Haproxy: 2.0
我检查了码头文档是否存在超时,我们已经配置了所有超时,但是仍然不知道为什么线程会无限期挂起。我们有相同的线程转储,
34534543535345435(DNS) - Tue Aug 13 04:40:06 PDT 2019" #1081 prio=5 os_prio=0 tid=0x00007f93e40d3000 nid=0xd820 waiting on condition [0x00007f91c7cfa000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x00000000d9648be0> (a java.util.concurrent.CountDownLatch$Sync)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:836)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer.java:997)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1304)
at java.util.concurrent.CountDownLatch.await(CountDownLatch.java:231)
at org.eclipse.jetty.client.util.FutureResponseListener.get(FutureResponseListener.java:100)
at org.eclipse.jetty.client.HttpRequest.send(HttpRequest.java:683)
at com.adventnet.webmon.util.LocationTestUtil.getLocationResponse(LocationTestUtil.java:430)
at com.adventnet.webmon.util.LocationTestUtil.getLocationResponse(LocationTestUtil.java:219)
at com.adventnet.webmon.conf.server.ConfDataCollection.doMultiLocationDC(ConfDataCollection.java:3192)
at com.adventnet.webmon.conf.server.ConfDataCollection.getResponseData(ConfDataCollection.java:2703)
at com.adventnet.webmon.conf.server.ConfDataCollection.invokeDataCollection(ConfDataCollection.java:479)
at com.adventnet.webmon.conf.task.ConfMonitorTask.run(ConfMonitorTask.java:676)
at com.zoho.scheduler.JobWrapper.invokeRunnableJob(JobWrapper.java:116)
at com.zoho.scheduler.instrument.WrappedJobWrapper.invokeRunnableJob(WrappedJobWrapper.java:34)
at com.zoho.scheduler.JobWrapper.executeJob(JobWrapper.java:89)
at com.zoho.scheduler.JobWrapper.run(JobWrapper.java:47)
at com.adventnet.taskengine.inmemory.TaskExecutor$2.call(TaskExecutor.java:113)
at com.adventnet.sas.scheduler.inmemory.WrappedSASExecutorListener.call(WrappedSASExecutorListener.java:33)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
最大的问题是它不会在测试网格中发生,而只会在生产服务器中发生。
请帮助解决此问题
TIA