https://linen.dev logo
#help
Title
# help
t

Todor Avramov

02/16/2024, 10:39 PM
Hello 👋 We trigger a webhook with
postServeActions
. Our JSON config is just about identical to the example provided in https://wiremock.org/docs/webhooks-and-callbacks/#creating-a-simple-single-webhook Wiremock returned 200 OK to the caller and then proceeded to asynchronously send the webhook. However, wiremock errored out with a connection timeout error.
Copy code
Failed to fire webhook POST <https://xyz.com/webhook/>

"wiremock.org.apache.hc.client5.http.HttpHostConnectException: Connect to <https://xyz.com:443> [<http://xyz.com/XXX.XXX.XXX.XXX|xyz.com/XXX.XXX.XXX.XXX>] failed: Connection timed out (Connection timed out)
	at java.base/java.net.PlainSocketImpl.socketConnect(Native Method)
	at java.base/java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
	at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
	at java.base/java.net.AbstractPlainSocketImpl.connect(Unknown Source)
	at java.base/java.net.SocksSocketImpl.connect(Unknown Source)
	at java.base/java.net.Socket.connect(Unknown Source)
	at wiremock.org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory.lambda$connectSocket$0(SSLConnectionSocketFactory.java:232)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at wiremock.org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:231)
	at wiremock.org.apache.hc.client5.http.impl.io.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:181)
	at wiremock.org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:447)
	at wiremock.org.apache.hc.client5.http.impl.classic.InternalExecRuntime.connectEndpoint(InternalExecRuntime.java:162)
	at wiremock.org.apache.hc.client5.http.impl.classic.InternalExecRuntime.connectEndpoint(InternalExecRuntime.java:172)
	at wiremock.org.apache.hc.client5.http.impl.classic.ConnectExec.execute(ConnectExec.java:142)
	at wiremock.org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
	at wiremock.org.apache.hc.client5.http.impl.classic.ProtocolExec.execute(ProtocolExec.java:192)
	at wiremock.org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
	at wiremock.org.apache.hc.client5.http.impl.classic.InternalHttpClient.doExecute(InternalHttpClient.java:170)
	at wiremock.org.apache.hc.client5.http.impl.classic.CloseableHttpClient.execute(CloseableHttpClient.java:245)
	at wiremock.org.apache.hc.client5.http.impl.classic.CloseableHttpClient.execute(CloseableHttpClient.java:188)
	at wiremock.org.apache.hc.client5.http.impl.classic.CloseableHttpClient.execute(CloseableHttpClient.java:162)
	at com.github.tomakehurst.wiremock.http.client.ApacheBackedHttpClient.execute(ApacheBackedHttpClient.java:51)
	at org.wiremock.webhooks.Webhooks.lambda$triggerWebhook$0(Webhooks.java:98)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
	at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.base/java.lang.Thread.run(Unknown Source)
",
Can wiremock be configured to retry on retryable network errors? Or is that a new feature request? In general, 500-range responses and connection timeout errors should be considered retryable.
t

Tom

02/17/2024, 11:06 AM
You could get retries working by supplying a custom HTTP client to WireMock on startup (which might just be a retry wrapper around the default client). Otherwise yes, this would be new a feature request.
t

Todor Avramov

02/17/2024, 4:40 PM
We are running the wiremock docker image in kubernetes so supplying a custom HTTP client is not an option for us. I will see if I can make a contribution to the code. Thanks for your reply.
t

Tom

02/19/2024, 9:54 AM
You could package your client in a JAR file then drop this in the extensions directory the WireMock Docker image adds to the classpath. Provided you’ve put the service loader file in the extension JAR WireMock will scan and automatically load your client impl.
6 Views