Hi there, could please someone help me with the do...
# help
e
Hi there, could please someone help me with the docker & createNewStub issue, I'll add now some details in the thread
my docker compose file
Copy code
cat mock/docker-compose.yml                                                                                                                                                                                                     1/s001 [15:25:12] 
services:
  wiremock:
    image: "wiremock/wiremock:latest"
    container_name: wiremock
    entrypoint: ["/docker-entrypoint.sh", "--global-response-templating", "--disable-gzip", "--verbose"]
    expose:
      - 8080
      - 5000
    ports:
      - "8080:8080"
      - "5000:5000"
    volumes:
      - ./extensions:/var/wiremock/extensions
      - ./__files:/var/wiremock/__files
      - ./mappings:/var/wiremock/mappings
the request I'm sending
Copy code
curl --request POST \                                                                                                                                                                                                           0/s001 [15:25:28] 
  --url <http://localhost:8080/__admin/mappings> \
  --header 'Content-Type: application/json' \
  --header 'User-Agent: insomnia/10.3.1' \
  --data '{
    "name": "Hello world!",
    "request": {
        "method": "GET",
        "url": "/some/thing",
                "port": 5000
    },
    "response": {
        "status": 200,
        "body": "Hello world!",
        "headers": {
            "Content-Type": "text/plain"
        }
    }
}'
{
  "id" : "5fec9412-331a-468e-8ec9-4e8b891be9ad",
  "name" : "Hello world!",
  "request" : {
    "port" : 5000,
    "url" : "/some/thing",
    "method" : "GET"
  },
  "response" : {
    "status" : 200,
    "body" : "Hello world!",
    "headers" : {
      "Content-Type" : "text/plain"
    }
  },
  "uuid" : "5fec9412-331a-468e-8ec9-4e8b891be9ad"
}%
what mapping shows:
Copy code
{
  "mappings": [
    {
      "id": "5fec9412-331a-468e-8ec9-4e8b891be9ad",
      "name": "Hello world!",
      "request": {
        "port": 5000,
        "url": "/some/thing",
        "method": "GET"
      },
      "response": {
        "status": 200,
        "body": "Hello world!",
        "headers": {
          "Content-Type": "text/plain"
        }
      },
      "uuid": "5fec9412-331a-468e-8ec9-4e8b891be9ad"
    }
  ],
  "meta": {
    "total": 1
  }
}
the problem
when I do from host:
Copy code
curl --request GET --url <http://localhost:5000/some/thing> --header 'User-Agent: insomnia/10.3.1' 
curl: (56) Recv failure: Connection reset by peer
when I do from inside of the docker
Copy code
root@6f085eb0456e:/home/wiremock# curl --request GET --url <http://localhost:5000/some/thing> --header 'User-Agent: insomnia/10.3.1' 
curl: (7) Failed to connect to localhost port 5000 after 0 ms: Couldn't connect to server
what do I do wrong? can please someone point me on the reason why I cannot connect on 5000 port?
this doc https://wiremock.org/docs/standalone/admin-api-reference/#tag/Stub-Mappings/operation/createNewStubMapping says I can use the port, but it looks like wiremock doesn't listen at 5000
l
It looks like you are exposing port 5000 in your docker compose file but you are not starting wiremock on port 5000. By default wiremock starts on port 8080 if you don't specify an option to change it. You would need to specify the
--port
option to start wiremock on port 5000 https://wiremock.org/docs/standalone/java-jar/#command-line-options
e
I'm about to use one wiremock server for different services so the endpoints can be interfering, that's why I specified the port 5000. Do you recommend in that case just start different wiremock servers for each mocked service?
thank you for the answer
I just want to have one wiremock docker for different services, and to divide that different services by the ports
l
It largely depends on your setup. I know some wiremock users run multiple wiremock instances - 1 for each service whereas others have a common root path (
/invoices
,
/payments
for example) so they run one instance and their stubs don't interfere with each other
v
hi @Lee Turner. I have the same problem. I've used Mountebank for mocking dependencies before and it was working this way, by opening mappings on separate ports. I.e., you have mountebank.mynetwork.local:5000 for mocking one dependency and mountebank.mynetwork.local:6000 for another. That's very convenient for having a single mock server and mocking several dependencies with it. Wiremock allows to define port for request stubbing, but it doesn't listen on that port. That confuses me, if whole service works on a single port, what's the point in specifying port in mapping?
👍 1
If that's not the way Wiremock works right now, could you consider this enhancement? To start listening on specified port when creating new mapping?
@Lee Turner, @Tom, ?
@Lee Turner, @Tom, ?
l
Hi, this isn't currently how WireMock works. The port you are specifying in your mapping is just a request matcher and has nothing to do with the port that WireMock is bound to when it starts up. I am not sure we would want to link request matchers to the startup functionality of wiremock
v
@Lee Turner, thank you for your reply. Is it possible to make WireMock listening for range of ports on startup? That would perfectly cover my use-case. I've tried to use
--port
property for that, but it seems that it accepts only a single port.
l
Unfortunately that is a bit of an bigger architectural change. It isn't something we would be able to focus on as a team at this point in time.