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

Patryk

08/21/2023, 11:12 AM
Hi, I'm trying to use wiremock as a proxy to record the traffic. I got it to work in the standalone version with the following config:
Copy code
java ^
-jar wiremock-jre8-standalone-2.35.0.jar ^
--port 9999 ^
--enable-browser-proxying ^
--https-truststore="C:\clientKeystore.pfx" ^
--truststore-password="changeit" ^
--record-mappings
I want to start wiremock from java, so I tried to convert my standalone config to java config as follows:
Copy code
public void setupWiremock() {
    wireMockServer = new WireMockServer(
            options()
                    .port(9999)
                    .enableBrowserProxying(true)
                    .trustStorePath("C:/clientKeystore.pfx")
                    .trustStorePassword("changeit")
                    .notifier(new ConsoleNotifier(true))
    );
    wireMockServer.enableRecordMappings(
            new SingleRootFileSource("src/test/resources/wiremock/mappings"),
            new SingleRootFileSource("src/test/resources/wiremock/files")
    );
    wireMockServer.start();
}
The standalone config works as expected. I can send an API request and get a 200 return code. The Java config however does not work as I get a 500 code with the following response body from the proxied request:
Copy code
Network failure trying to make a proxied request from WireMock to secured-api.dev.internal/projects/5c35fef2-4010-11ee-be56-0242ac120002
Target host is not specified
This doesn't make any sense to me as 1. the "same" standalone config works as expected, and 2. the error message says that the target host is unspecified, but the same message contains the target host (secured-api.dev.internal). A possibility for the unspecified target host could be a missing protocol (https) but I don't know why wiremock should be missing that info when it already got the rest of the URI. I am thankful for any help. Thank you in advance.
t

Tom

08/21/2023, 2:23 PM
Hi @Patryk recording in this way doesn’t work through WireMock 2.x, but does in the latest 3.x betas. Try switching the JAR to wiremock-standalone-3.0.0-beta-15.jar
🙌 1
2 Views