【问题标题】:Dapr Client Docker Compose IssueDapr 客户端 Docker 撰写问题
【发布时间】:2021-05-03 17:37:17
【问题描述】:

我尝试在本地 Docker 实例中与 Dapr 集成 3 个服务。每个服务都在 Linux 容器中运行。

version: '3.4'
networks:
  NextWare:
    external: true
services:
  nextware.daprtest.service1.api:
    environment:
      - ASPNETCORE_ENVIRONMENT=Development
      - DAPR_GRPC_PORT=40001
    ports:
      - "40001:40001" # Dapr instances communicate over gRPC so we need to expose the gRPC port
      - "4001:80"
    depends_on:
      - redis
      - placement
    networks:
      - NextWare
    volumes:
      - ${APPDATA}/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro

  nextware.daprtest.service1.api-dapr:
    image: "daprio/daprd:edge"
    command: [
      "./daprd",
     "-app-id", "nextware.daprtest.service1.api",
     "-app-port", "3001",
     "-dapr-grpc-port", "40001",
     "-metrics-port", "9091",
     "-placement-host-address", "placement:50006", # Dapr's placement service can be reach via the docker DNS entry
     "-components-path", "/components"]

    volumes:
        - "./components/nextware.daprtest.service1.api:/components" # Mount our components folder for the runtime to use
    depends_on:
      - nextware.daprtest.service1.api
    network_mode: "service:nextware.daprtest.service1.api" # Attach the nodeapp-dapr service to the nodeapp network namespace

  nextware.daprtest.service2.api:
    environment:
      - ASPNETCORE_ENVIRONMENT=Development
      - DAPR_GRPC_PORT=40003
    ports:
      - "40003:40003" # Dapr instances communicate over gRPC so we need to expose the gRPC port
      - "4003:80"
    depends_on:
      - redis
      - placement
    networks:
      - NextWare
    volumes:
      - ${APPDATA}/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro

  nextware.daprtest.service2.api-dapr:
    image: "daprio/daprd:edge"
    command: [
      "./daprd",
     "-app-id", "nextware.daprtest.service2.api",
     "-app-port", "3003",
     "-dapr-grpc-port", "40003",
     "-metrics-port", "9093",
     "-placement-host-address", "placement:50006" # Dapr's placement service can be reach via the docker DNS entry
     ]
    volumes:
        - "./components/nextware.daprtest.service2.api:/components" # Mount our components folder for the runtime to use
    depends_on:
      - nextware.daprtest.service2.api
    network_mode: "service:nextware.daprtest.service2.api" # Attach the nodeapp-dapr service to the nodeapp network namespace


  nextware.daprtest.service3.api:
    environment:
      - ASPNETCORE_ENVIRONMENT=Development
      - DAPR_GRPC_PORT=40005
    ports:
      - "40005:40005" # Dapr instances communicate over gRPC so we need to expose the gRPC port
      - "4005:80"
    depends_on:
      - redis
      - placement
     
    networks:
      - NextWare
    volumes:
      - ${APPDATA}/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro


  nextware.daprtest.service3.api-dapr:
    image: "daprio/daprd:edge"
    command: [
      "./daprd",
     "-app-id", "nextware.daprtest.service3.api",
     "-app-port", "3005",
     "-dapr-grpc-port", "40005",
     "-metrics-port", "9095",
     "-placement-host-address", "placement:50006" # Dapr's placement service can be reach via the docker DNS entry
     ]
    volumes:
        - "./components/nextware.daprtest.service3.api:/components" # Mount our components folder for the runtime to use
    depends_on:
      - nextware.daprtest.service3.api
    network_mode: "service:nextware.daprtest.service3.api" # Attach the nodeapp-dapr service to the nodeapp network namespace

运行 Docker PS 我看到以下容器..

服务启动并运行后,我尝试将以下代码从 Service3 调用到 Service1 ...

 var request = _mapper.Map<UpdateRequest>(integrationCommand);
 await _daprClient.InvokeMethodAsync("nextware.daprtest.service1.api", "Update", request, cancellationToken);

我收到以下异常...

RequestUri 是否正确...

“http://127.0.0.1:3500/v1.0/invoke/nextware.daprtest.service1.api/method/Update”

鉴于这是调用边车的 DaprClient,我假设上面的 RequestUri 是正确的。

我错过了什么?

【问题讨论】:

  • 我在 Tye 中运行时遇到完全相同的错误...我认为这是一个 gRPC 问题。 .

标签: c# asp.net-core docker-compose microservices dapr


【解决方案1】:

错误的原因是 ID 和方法名格式错误。

我从 Docker compose 转到 Tye 并遇到了同样的问题。

然后我根据此屏幕截图更改了调用。

虽然这仍然没有调用 Update 方法,但它不再返回 500 异常。

相反,我得到了以下异常,我同样难以解决......

远程证书根据验证程序无效:RemoteCertificateNameMismatch, RemoteCertificateChainErrors

这是由于我注释掉了以下启动配置设置,之后一切正常...

Dapr 摇滚!

【讨论】:

  • 嘿,非常感谢,我在 docker-compose 中也遇到了服务到服务调用的问题。通过检查您的配置,我设法解决了我的问题。非常感谢你.. :-)
猜你喜欢
  • 2022-11-01
  • 1970-01-01
  • 2021-03-04
  • 2021-12-02
  • 2020-09-24
  • 2012-11-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多