我有一个奇怪的问题,即我向邮递员发出的请求(对我的Mercure集线器)工作正常,但是使用Symfony HttpClient的Publisher类(来自Symfony mercure bundle 包)将产生响应代码0。
根据我的研究,这意味着找不到URL,或者没有返回响应?

我首先认为它可能与Publisher类本身有关,这就是为什么打开此Issue on Github的原因,但是经过一番尝试之后,我认为容器可能发生通信错误?我尝试给我的 Mercurial 容器提供“网络:内部”,其他一些容器也使用该容器,但这也无济于事。

任何想法都将不胜感激。

/ e:我的docker-compose:

version: "3"

services:
  traefik:
    image: traefik:v1.7
    ports:
      - 80:80
      - 443:443
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ./.docker/traefik/traefik.toml:/etc/traefik/traefik.toml
    networks:
      - proxy
    labels:
      - traefik.enable=true
      - traefik.docker.network=proxy
      - traefik.frontend.rule=Host:traefik.heracles.local
      - traefik.port=8080

  nginx:
    image: nginx:1.17-alpine
    volumes:
      - ./Source:/var/www
      - ./.docker/nginx/conf/nginx.conf:/etc/nginx/nginx.conf
    links:
      - php
    networks:
      - internal
      - proxy
    labels:
      - traefik.docker.network=proxy
      - traefik.enable=true
      - traefik.basic.frontend.rule=Host:heracles.local
      - traefik.basic.port=80

  php:
    build:
      args:
        USER_ID: ${USER_ID}
      context: ./.docker/php
    volumes:
      - ./Source:/var/www
      - ./.docker/php/conf/cli.ini:/etc/php/7.4/cli/conf.d/zz-symfony.ini
      - ./.docker/php/conf/fpm.ini:/etc/php/7.4/fpm/conf.d/zz-symfony.ini
      - ./.docker/php/conf/xdebug.ini:/etc/php/7.4/fpm/conf.d/zz-xdebug.ini
      - ./.docker/php/conf/opcache.ini:/etc/php/7.4/fpm/conf.d/zz-opcache.ini
      - ./.docker/php/conf/pool.conf:/etc/php/7.4/fpm/pool.d/www.conf
    networks:
      - internal
    labels:
      - traefik.enable=false

  db:
    image: mysql:5.7
    env_file:
      - .env
    volumes:
      - db_data:/var/lib/mysql
      - ./.docker/mysql/conf.d:/etc/mysql/conf.d
    command:
      - --character-set-server=utf8mb4
      - --collation-server=utf8mb4_unicode_ci
      - --skip-character-set-client-handshake
    networks:
      - internal
    labels:
      - traefik.enable=false
    restart: always

  adminer:
    image: adminer
    networks:
      - internal
      - proxy
    labels:
      - traefik.docker.network=proxy
      - traefik.enable=true
      - traefik.basic.frontend.rule=Host:db.heracles.local
      - traefik.basic.port=8080

  blackfire:
    image: blackfire/blackfire
    networks:
      - internal
    labels:
      - traefik.enable=false

  mailhog:
    image: mailhog/mailhog
    networks:
      - internal
      - proxy
    labels:
      - traefik.docker.network=proxy
      - traefik.enable=true
      - traefik.basic.frontend.rule=Host:mail.heracles.local
      - traefik.basic.port=8025

  mercure:
    image: dunglas/mercure
    environment:
      - ALLOW_ANONYMOUS=1
      - CORS_ALLOWED_ORIGINS=*
      - JWT_KEY=ASD
      - PUBLISH_ALLOWED_ORIGINS=http://heracles.local
      - ADDR=:3000
    ports:
      - 3000:3000

networks:
  internal:
  proxy:
    external: true

volumes:
  db_data:

最佳答案

参考您的注释,您的MERCURE_PUBLISH_URL .env变量确实必须引用您的Mercure容器,但是不需要端口指示。如果您的Mercure容器的名称为“mercure”,则应按以下方式设置环境变量:
MERCURE_PUBLISH_URL=http://mercure/.well-known/mercure
(如果您的连接受到保护,请用http替换https)

07-24 13:46