AsyncHttpClient / async-http-client

Asynchronous Http and WebSocket Client library for Java
Other
6.29k stars 1.59k forks source link

Failure to complete SSL handshake is reported as a timeout #1242

Closed clayreimann closed 8 years ago

clayreimann commented 8 years ago

When trying to connect over https to a remote server I observed the async-client sending an RST after the Server Key Exchange, which causes the server to send FIN, ACK. This ends up shutting down the session early (without the payload going across the wire). However instead of some sort of SSL exception I received the following exception:

java.util.concurrent.TimeoutException: Request timeout to symbol-service.zenfs.com/98.139.239.224:443 after 5000 ms
    at org.asynchttpclient.netty.timeout.TimeoutTimerTask.expire(TimeoutTimerTask.java:43)
    at org.asynchttpclient.netty.timeout.RequestTimeoutTimerTask.run(RequestTimeoutTimerTask.java:48)
    at io.netty.util.HashedWheelTimer$HashedWheelTimeout.expire(HashedWheelTimer.java:588)
    at io.netty.util.HashedWheelTimer$HashedWheelBucket.expireTimeouts(HashedWheelTimer.java:662)
    at io.netty.util.HashedWheelTimer$Worker.run(HashedWheelTimer.java:385)
    at java.lang.Thread.run(Thread.java:745)

I'm interested in fixing this issue (both the misleading exception, and the handshake failure) so if someone could point help me figure out where to start I'd appreciate it.

slandelle commented 8 years ago

Are you sure this is an issue? The request timeout accounts for the total request-response transaction, so it includes the tcp connect and the tls handshake (if a proper connection could not be fetched from the pool). If under load the one on them starts lagging, or if the connect and handshake timeouts are configured with values close to the request timeout, it's perfectly possible to get a request timeout first.

clayreimann commented 8 years ago

Perhaps the type of error I'm seeing is not wrong, it could just be a connect timeout, but the behavior of:

Server: Server Key Exchange
Client: RST
Server: FIN, ACK
Client: <ok lets wait for a while>

seems wrong. I would expect that when the server sends FIN the client's Future would immediately complete with error.

slandelle commented 8 years ago

Client:

This is something new that you didn't mention in your initial report.

I would expect that ... the client's Future would immediately complete with error.

Isn't it how you get the TimeoutException?

Could you please provide a reproducer?

clayreimann commented 8 years ago

When trying to connect over https to a remote server I observed the async-client sending an RST after the Server Key Exchange, which causes the server to send FIN, ACK. This ends up shutting down the session early

And I get the TimeoutException later, not when async-http aborts the handshake.

I'll work on a reproducer.

slandelle commented 8 years ago

And I get the TimeoutException later, not when async-http aborts the handshake.

Ahhhhhhhhhh, ok! It looks like a Netty bug.

Yes, a reproducer would definitively help!

cc @normanmaurer

slandelle commented 8 years ago

@clayreimann Ping. If no response, I'll have to close

clayreimann commented 8 years ago

@slandelle Haven't gotten time to dig into this and generate a reproduction case. I'll reopen when I get to it

slandelle commented 8 years ago

OK. Thanks for the update.