How to get Dapr Service to Service Invocation to work when running under docker-compose

0 votes

When I try to use the Dapr SDK to call a service, I get the following error.

System.Net.Http.HttpRequestException: Connection refused (127.0.0.1:3500)
 ---> System.Net.Sockets.SocketException (111): Connection refused

Here are the settings for the service I'm trying to call in docker-compose:

 quest-service:
    image: ${DOCKER_REGISTRY-gamification}/quest-service:${TAG:-latest}
    environment:
      - ASPNETCORE_ENVIRONMENT=Development
      - ASPNETCORE_URLS=http://0.0.0.0:80
      - SeqServerUrl=http://seq
    build:
      context: .
      dockerfile: Services/LW.Gamification.QuestService/Dockerfile
    ports:
      - "5110:80"
      - "50010:50001"

  quest-service-dapr:
    image: "daprio/daprd:latest"
    command: ["./daprd",
      "-app-id", "Quest-Service",
      "-app-port", "80",
      "-components-path", "/Components",
      "-config", "/Configuration/config.yaml"
      ]
    volumes:
      - "./Dapr/Components/:/Components"
      - "./Dapr/Configuration/:/Configuration"
    depends_on:
      - quest-service
    network_mode: "service:quest-service"

The caller's settings are as follows:

player-service:
    image: ${DOCKER_REGISTRY-gamification}/player-service:${TAG:-latest}
    environment:
      - ASPNETCORE_ENVIRONMENT=Development
      - ASPNETCORE_URLS=http://0.0.0.0:80
      - SeqServerUrl=http://seq
    build:
      context: .
      dockerfile: Services/LW.Gamificaiton.PlayerService/Dockerfile
    ports:
      - "5109:80"
      - "50009:50001"

  player-service-dapr:
    image: "daprio/daprd:latest"
    command: ["./daprd",
      "-app-id", "Player-Service",
      "-app-port", "80",
      "-components-path", "/Components",
      "-config", "/Configuration/config.yaml"
      ]
    volumes:
      - "./Dapr/Components/:/Components"
      - "./Dapr/Configuration/:/Configuration"
    depends_on:
      - player-service
    network_mode: "service:player-service"

And here's the code that's not working:

            // demo service to service call
            var httpClient = DaprClient.CreateInvokeHttpClient("Quest-Service");
            var requestUri = $"api/v1/Quest";

            var result = await httpClient.GetFromJsonAsync<IEnumerable<string>>(requestUri);

PS: Messaging appears to be operating properly. 

I'm new to Dapr, so I'm sure I'm doing something foolish incorrectly, perhaps with ports. I'm just not sure!

Apr 29, 2022 in Docker by Abhijeet
• 180 points

edited 5 days ago 11 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP