Apache HttpClient Throws "NoHttpResponseException:[server] failed to respond" calling WireMock

1,568 views
Skip to first unread message

Robert Lukens

unread,
Feb 7, 2016, 4:03:15 PM2/7/16
to wiremock-user
Im running into occasional failures when running tests that use WireMock to stub an external call.   The call to the WireMock server fails and the Apache HttpClient (4.5) throws an "NoHttpResponseException:[server] failed to respond" exception.  

After researching the issue on the client side, it appears to boil down to a stale http connection the http client is re-using that the Jetty server has closed.  I was able to configure the http client to not reuse connections and the issue has cleared up.  Was wondering if anyone had run into something like this before.   It only happens on PUT/POST/PATCH request since the http client retry mechanism does not support retrying these operations.  Would like to differentiate this as an issue with the test code or production code.

Any insight appreciated.

Note: Occasional == doesn't happen at all,  then the suite is changed (i.e. a new test is added with a new stub) and then the failure happens consistently at a random place in the suite where a call to WireMock server is made.

Tom Akehurst

unread,
Feb 7, 2016, 4:40:20 PM2/7/16
to wiremock-user
So if I understand correctly - the server you're proxying onto is improperly terminating connections, which WireMock's HTTP client is pooling and attempting to re-use?

Could you post any additional details about the server/service which is causing this?
Reply all
Reply to author
Forward
0 new messages