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
Allow stubbing a response for connection timeouts #591
Comments
I tried to do this in WireMock 1.x by overriding the socket If you've got another way you think this could work, then it'd be great to have it back. Have you got a specific strategy in mind? |
Right now, I'm using a separate socket for those tests along those lines which results in the expected behavior. Not sure yet if we can do something similar with Jetty though. I'll have a look.
|
Interesting. I spent quite a while messing around with the backlog parameter, and I couldn't seem to get the desired behaviour. The Javadocs mention that there's some platform-dependent behaviour in the use of the backlog parameter, so this might have been why. If you can find a way to get this working reliably at least across the major JVM impls, then I guess it should be possible somehow to override Jetty's default socket factory and insert this behaviour. |
did any body found a way to simulate connection timeout behaviour? |
@bmuskalla I have tried to simulate SocketTimeoutException using #withFixedDelay. I always get SocketException. Can you please help me with the stubbing? |
Anyone can have an answer? I'm able to simulate Read timeout with |
@plum117 By Just shutting down the wiremock, you will get ConnectException |
It's basically impossible to reliably force connection timeouts in pure Java at the moment. It used to be the case that you could inject a delay before calling My recommendation at the moment would be to use a tool that works at the level of the network stack. |
BTW, shutting down WireMock won't have the same effect - when a port is not being listened on, you get a TCP |
Using #withFixedDelay works great to test and simulate SocketTimeoutException. The same should be possible for simulating connection timeouts.
If you agree, I'm happy to contribute something like Fault#REFUSE_CONNECTION
The text was updated successfully, but these errors were encountered: