[
https://issues.apache.org/jira/browse/CXF-9267?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18136248#comment-18136248
]
Valentino Porta commented on CXF-9267:
--------------------------------------
Here the reproducer: [https://github.com/vp340/cxf-log-example/tree/CXF-9267]
You can use the mock services that is already in the address of che CxfEndpoint
... it has a limit of 50 calls per day I think ...but if U play it well ...with
connection timeouts ... the counters doesn't go up ;) .
In order to reproduce on your machine here the steps:
* run the command: curl -o /dev/null -s -w "Latency TCP (Connect):
%\{time_connect}s\nLatency SSL (Handshake): %\{time_appconnect}s\nTime total
response: %\{time_total}s\n"
[https://mp4af2bb6577f48a3dcd.free.beeceptor.com|https://mp4af2bb6577f48a3dcd.free.beeceptor.com/]
You should see:
Latency TCP (Connect): 0.177527s
Latency SSL (Handshake): 0.362268s (only for https)
Time total response: 0.536233s
* grab the Latency TCP (if http) ...or Latency SSL (if https... handshake is
included) ... and set it as your ConnectionTimeout in the conduit (usually I
set it a little bit less... but U need to try I could depend upon your pc)
* fire some request (see in the resources) ....U should see alternatively the
4 error that I cited above... so the publisher one...
* then if U build my PR... include it and run agains... only real timeout
appears
If U need any help I am here...ask me anything. :)
> Race Condition in HttpClientHTTPConduit.HttpClientBodyPublisher hides
> Connection Timeout exception
> --------------------------------------------------------------------------------------------------
>
> Key: CXF-9267
> URL: https://issues.apache.org/jira/browse/CXF-9267
> Project: CXF
> Issue Type: Bug
> Components: Transports
> Affects Versions: 4.0.11, 4.1.9, 4.2.4
> Reporter: Valentino Porta
> Priority: Major
> Attachments: close.png, histogram.png, noPublisher.png,
> publisher_byte.png
>
>
> Hi everyone,
> I think we have a similar problem as the
> https://issues.apache.org/jira/browse/CXF-9135 also in the
> HttpClientHTTPConduit.HttpClientBodyPublisher .
>
> Let me explain.
> I noticed that a race condition can happen where the [caller thread] close
> the HttpClientBodyPublisher.close ...that set the stream=null ... and then
> the [http client thread] try to subscribe to it... but finding stream==null
> it gets a noBody() ... resulting in a "SocketTube(1) [HttpClient-1-Worker-0]
> Too few bytes returned by the publisher (0/241)" Exception ... that covers
> the real error (Connection Timed out).
>
> I noticed experimentally that this happens when :
> * AllowChunking="true" in the Conduit
> * payload are under chunkingThreshold (<4096) ... (I managed to replicate
> only this scenario... I don't know for sure that also other are affected)
> * Connection Timeout happens to be set as EXACTLY the value of the real
> network delay
> I will attach a reproducer as soon as I close this ... with specific
> instructions to replicate :) .
>
> I also attach a screen of errors that I have that demonstrate that the max of
> Too few bytes returned by the publisher (0/241) is approximately 4096... (It
> could be also because it's the threshold so for sure there couldn't be
> (0/8000) .... ) (publisher_byte.png).
> ...and some other screens to proof that the 2 threads are running into each
> other!
>
> Before I said 'EXACTLY' because (see histogram.png) I run some test pointing
> to a free mock services online (thanks for the help
> [https://app.beeceptor.com|https://app.beeceptor.com/)] ...) ...in order to
> simulate some latency (my local wiremock was too fast and I had to set
> timeout at 1/2 ms ).
> The real latency of the network was 180ms ... (see the reproducer under to
> get command) .
> If I set connection timeout...I get that type of errors:
> * 10<<180:
> ** Could not send Message.
> ** HTTP connect timed out
> * 180 ≃ 180
> ** Could not send Message.
> ** HTTP connect timed out
> ** request timed out (...I have no idea why and where this was thrown...but
> yes)
> ** SocketTube(1) [HttpClient-1-Worker-0] Too few bytes returned by the
> publisher (0/241)
> ** SSLTube(SocketTube(5)) stream=1 [HttpClient-1-Worker-0] Too few bytes
> returned by the publisher (0/241)
> * 1000 >> 180 :
> ** OK 200
> Our race conditions are:
> * SocketTube if I was using "http".
> * SSLTube(SocketTube(5)) if I was using "https".
> I will try open a PR... I already try some local build and setup some tests
> ;)
>
>
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)