-
Notifications
You must be signed in to change notification settings - Fork 37.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Connection prematurely closed BEFORE response when using Spring WebClient with Wiremock proxy #27518
Comments
Hello @vetler, I believe I'm facing a similar problem when I'm using MockWebServer to test a WebClient. The connection is being closed before receiving response from MockWebServer (with same reason). Those repositories you shared are inaccessible (at least for me). Are they set as private? |
Whoops, yes the repository was private. Should be public now, @rafamdr |
I've just tested and JettyClientHttpConnector also worked for my case. |
This was also reported in Spring-Boot-Admin (for instance codecentric/spring-boot-admin#1711 ) by multiple users. It may not be connected to wiremock specifically since wiremock was not involved in those issues. |
Have you tried this with Reactor Netty HttpClient directly? It might be unrelated to the WebClient if it works with other connectors. |
That's a great point, will try to find the time to create a test case for that as well. |
Reactor Netty HttpClient test case created and reported in Reactor Netty here: reactor/reactor-netty#1857 |
When getting a URL using Spring
WebClient
withReactorClientHttpConnector
, and using Wiremock as a proxy, it fails withConnection prematurely closed BEFORE response
, see stack trace below.The same setup works fine with other HTTP client libraries, at least with okhttp3.
Hopefully the example code included should be easy enough to understand.
Wiremock is set up to enable proxying, all requests are set to return the string "foo" as text/plain.
When making a request with WebClient, the result is expected to be "foo", but it instead fails with the stack stack trace as shown below.
See example at the end, and also a runnable test in the Git repository here: https://github.com/vetler/spring-webclient-bug
This works fine with
JettyClientHttpConnector
, branch with passing test for that here: https://github.com/vetler/spring-webclient-bug/tree/test/jettyclienthttpconnectorHere is a test to reproduce:
The text was updated successfully, but these errors were encountered: