在 ASP .NET core 3.1

问题描述

我正在尝试使用 docker-compose 运行多个微服务,依靠 DAPR 在它们之间建立通信。但是,即使开发人员 shell 日志说 DAPR sidecar 已启动并正在运行,我也无法在 DAPR 仪表板中看到它们,也无法调用使用它们的方法

我已经按照 https://docs.microsoft.com/en-us/dotnet/architecture/dapr-for-net-developers/getting-started 和谷歌的说明进行了很多操作,但找不到问题所在。

我还通过运行上述 Microsoft 示例成功获得预期结果,验证了 DAPR 已正确安装。

这是我的 docker-compose.yml 文件

version: '3.4'

services:
  antivirus:
    image: mkodockx/docker-clamav:alpine

  users-db:
    image: mcr.microsoft.com/mssql/server
    ports:
      - "1401:1433"
    environment:
      ACCEPT_EULA: "Y"
      SA_PASSWORD: "Your+password123"

  physical-db:
    image: mcr.microsoft.com/mssql/server
    ports:
      - "1402:1433"
    environment:
      ACCEPT_EULA: "Y"
      SA_PASSWORD: "Your+password123"


  smartenergy.users:
    image: ${DOCKER_REGISTRY-}smartenergyusers
    build:
      context: .
      dockerfile: Smartenergy.Users/Dockerfile
    ports:
      - "6969:80"
      - "44372:443"
    depends_on:
      - users-db

  smartenergy.users-dapr:
    image: "daprio/daprd:latest"
    command: [ "./daprd","-app-id","smartenergyusers","-dapr-http-port","3500","-app-port","443","-app-ssl" ]
    depends_on:
      - smartenergy.users
    network_mode: "service:smartenergy.users"


  smartenergy.physical:
    image: ${DOCKER_REGISTRY-}smartenergyphysical
    build:
      context: .
      dockerfile: Smartenergy.Physical/Dockerfile
    ports:
      - "6970:80"
      - "44373:443"
    depends_on:
      - physical-db


  smartenergy.physical-dapr:
    image: "daprio/daprd:latest"
    command: [ "./daprd","smartenergyphysical","3501","-app-ssl" ]
    depends_on:
      - smartenergy.physical
    network_mode: "service:smartenergy.physical"

这里是 DAPR 日志文件

time="2021-06-14T12:37:02.5979749Z" level=info msg="application discovered on port 443" app_id=smartenergyphysical instance=307796672fab scope=dapr.runtime type=log ver=1.2.0

time="2021-06-14T12:37:09.8308681Z" level=info msg="application configuration loaded" app_id=smartenergyphysical instance=307796672fab scope=dapr.runtime type=log ver=1.2.0

time="2021-06-14T12:37:09.8570903Z" level=warning msg="Failed to init actors: actors: Couldn't connect to placement service: address is empty" app_id=smartenergyphysical instance=307796672fab scope=dapr.runtime type=log ver=1.2.0

time="2021-06-14T12:37:09.8592054Z" level=info msg="dapr initialized. Status: Running. Init Elapsed 18699.5997ms" app_id=smartenergyphysical instance=307796672fab scope=dapr.runtime type=log ver=1.2.0

我已验证两个微服务以及 MSsql 容器都在运行。但是尝试使用 DAPR 调用服务失败且没有响应。从 swagger UI 调用 api 方法按预期工作,但 DAPR 甚至似乎没有运行。

Swagger UI

Invocation attempt

有人知道是什么问题吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)