I am doing HTTP post requests and I get times to times "Connection was closed" and sometimes the requests not realy dispatched (without an exception):
015-11-23 16:30:34,917 ERROR [com.company.push.core.verticles.PushMessageVerticle] - <error send push to parse>
io.vertx.core.VertxException: Connection was closed
at io.vertx.core.http.impl.ClientConnection.handleClosed(ClientConnection.java:305)
at io.vertx.core.impl.ContextImpl.lambda$wrapTask$16(ContextImpl.java:333)
at io.vertx.core.impl.ContextImpl.executeFromIO(ContextImpl.java:225)
at io.vertx.core.net.impl.VertxHandler.channelInactive(VertxHandler.java:99)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:208)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:194)
at io.netty.handler.codec.ByteToMessageDecoder.channelInactive(ByteToMessageDecoder.java:306)
at io.netty.handler.codec.http.HttpClientCodec$Decoder.channelInactive(HttpClientCodec.java:212)
public class MyVerticle extends AbstractVerticle {
private static final int CONNS = 10000;
public void start() throws RuntimeException {
HttpClientOptions options = new HttpClientOptions().setSsl(true).
setTrustAll(true).setDefaultPort(443).
setKeepAlive(true).setMaxPoolSize(CONNS);
HttpClient client = vertx.createHttpClient(options);
vertx.eventBus().consumer(Constants.PUSH_MESSAGE_DEST_ADDRESS, (handler) -> {
{
String pushNotificationInJson = handler.body().toString();
HttpClientRequest request = client.request(HttpMethod.POST, "dest-url", "uri-params", response -> {
response.bodyHandler(b -> log.debug("response=" + b));
}).
putHeader("someHeaderKey", someHeadyVal).
putHeader("Content-Type", "application/json");
request.exceptionHandler(h -> {
client.close();
log.error("error send push", h);
});
request.setChunked(true);
request.write(pushNotificationInJson);
request.end();
}
});
}
thank you.