RESTEASY004655:无法调用请求:org.apache.http.NoHttpResponseException:host_url 未能响应
有时(随机发生,有时在一个请求后,有时在 10 个请求后)我的 Batch-Job 崩溃并出现以下异常:
javax.ws.rs.ProcessingException: RESTEASY004655: Unable to invoke request: org.apache.http.NoHttpResponseException: host_url failed to respond
at org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine.invoke(ApacheHttpClient4Engine.java:327)
at org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.invoke(ClientInvocation.java:443)
at org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.invoke(ClientInvocation.java:63)
at org.jboss.resteasy.client.jaxrs.internal.ClientInvocationBuilder.post(ClientInvocationBuilder.java:227)
异常是由以下代码触发的:
public YpspResponse sendRequest(YpspRequest request) {
return webTarget
.request(MediaType.APPLICATION_XML)
.post(Entity.xml(request))
.readEntity(YpspResponse.class);
}
WebTarget 使用此代码初始化:
ResteasyClientBuilder builder = new ResteasyClientBuilder()
.socketTimeout(30, TimeUnit.SECONDS)
.connectTimeout(5, TimeUnit.SECONDS)
.connectionPoolSize(500)
.keyStore(keyStore, ynetKeystorePassword.toCharArray())
.trustStore(trustStore);
if (proxyConfiguration.useProxy()){
logger.info("{}", proxyConfiguration.getHost());
builder.defaultProxy(proxyConfiguration.getHost(), proxyConfiguration.getPort());
}
return builder
.build()
.target(ynetUrl)
.register(messageBodyReader)
.register(loggingFilter)
.register((ClientRequestFilter) requestContext -> {
byte[] auth = (username + ":" + password).getBytes("UTF-8");
requestContext.getHeaders().putSingle(HttpHeaders.AUTHORIZATION, "BASIC " + Base64.getEncoder().encodeToString(auth));
requestContext.getHeaders().putSingle("version", "1.1");
});
我正在使用 RESTEASY:3.12.1.FINAL
看来 ResteasyClient
尝试使用已使用的连接而不是新连接。我该如何解决这个问题?
Sometimes (happens randomly, sometimes after one Requests and sometimes after 10) my Batch-Job crashes with the following Exception:
javax.ws.rs.ProcessingException: RESTEASY004655: Unable to invoke request: org.apache.http.NoHttpResponseException: host_url failed to respond
at org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine.invoke(ApacheHttpClient4Engine.java:327)
at org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.invoke(ClientInvocation.java:443)
at org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.invoke(ClientInvocation.java:63)
at org.jboss.resteasy.client.jaxrs.internal.ClientInvocationBuilder.post(ClientInvocationBuilder.java:227)
The exception is triggered from the following code:
public YpspResponse sendRequest(YpspRequest request) {
return webTarget
.request(MediaType.APPLICATION_XML)
.post(Entity.xml(request))
.readEntity(YpspResponse.class);
}
WebTarget is initialized with this code:
ResteasyClientBuilder builder = new ResteasyClientBuilder()
.socketTimeout(30, TimeUnit.SECONDS)
.connectTimeout(5, TimeUnit.SECONDS)
.connectionPoolSize(500)
.keyStore(keyStore, ynetKeystorePassword.toCharArray())
.trustStore(trustStore);
if (proxyConfiguration.useProxy()){
logger.info("{}", proxyConfiguration.getHost());
builder.defaultProxy(proxyConfiguration.getHost(), proxyConfiguration.getPort());
}
return builder
.build()
.target(ynetUrl)
.register(messageBodyReader)
.register(loggingFilter)
.register((ClientRequestFilter) requestContext -> {
byte[] auth = (username + ":" + password).getBytes("UTF-8");
requestContext.getHeaders().putSingle(HttpHeaders.AUTHORIZATION, "BASIC " + Base64.getEncoder().encodeToString(auth));
requestContext.getHeaders().putSingle("version", "1.1");
});
I am using RESTEASY: 3.12.1.FINAL
It appears that the ResteasyClient
tries to use an already used connection instead of a new one. How can I fix this issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
升级到3.15.2版本问题得到解决
Upgrade to 3.15.2 version issue gets resolve