Skip to content

Problem with mercure in production #704

@farestayari

Description

@farestayari

Hello,

after the deployment of the project on the server without https:

SERVER_NAME=my_ip_adresse:80 APP_SECRET=ChangeMe CADDY_MERCURE_JWT_SECRET=ChangeThisMercureHubJWTSecretKey docker compose -f compose.yaml -f compose.prod.yaml up -d --wait
the deployment is completed successfully and the project is running fine, but i got problems with mercure, all my mercure events are stuck on status pending as you can see in the screenshot below
image

here is my docker compose file, and i already replaced https with http :
`services:
php:
image: ${IMAGES_PREFIX:-}app-php
restart: unless-stopped
environment:
SERVER_NAME: ${SERVER_NAME:-localhost}, php:80

  MERCURE_PUBLISHER_JWT_KEY: ${CADDY_MERCURE_JWT_SECRET:-!ChangeThisMercureHubJWTSecretKey!}
  MERCURE_SUBSCRIBER_JWT_KEY: ${CADDY_MERCURE_JWT_SECRET:-!ChangeThisMercureHubJWTSecretKey!}
  # Run "composer require symfony/orm-pack" to install and configure Doctrine ORM
  # Run "composer require symfony/mercure-bundle" to install and configure the Mercure integration
  MERCURE_URL: ${CADDY_MERCURE_URL:-http://php/.well-known/mercure}
  MERCURE_PUBLIC_URL: ${CADDY_MERCURE_PUBLIC_URL:-http://${SERVER_NAME:-localhost}/.well-known/mercure}
  MERCURE_JWT_SECRET: ${CADDY_MERCURE_JWT_SECRET:-!ChangeThisMercureHubJWTSecretKey!}
  DATABASE_URL: postgresql://${POSTGRES_USER:-xxx}:${POSTGRES_PASSWORD:-xxxx}@database:5432/${POSTGRES_DB:-xxxxx}?serverVersion=${POSTGRES_VERSION:-15}&charset=${POSTGRES_CHARSET:-utf8}
  MESSENGER_HIGH_PRIORITY_DSN: amqp://guest:guest@rabbitmq:5672/%2f/high_priority
  MESSENGER_TRANSPORT_DSN: amqp://guest:guest@rabbitmq:5672/%2f/messages
depends_on:
  - rabbitmq
volumes:
  - .:/app:rw
  - caddy_data:/data
  - caddy_config:/config
ports:
  - target: 80
    published: ${HTTP_PORT:-80}
    protocol: tcp
  - target: 443
    published: ${HTTPS_PORT:-443}
    protocol: tcp
  - target: 443
    published: ${HTTP3_PORT:-443}
    protocol: udp
networks:
  - my-network`

in my env file i tried these attemtps :

###> symfony/mercure-bundle ###
# See https://symfony.com/doc/current/mercure.html#configuration
# The URL of the Mercure hub, used by the app to publish updates (can be a local URL)
#MERCURE_URL=[http://192.168.xx.xx:80/.well-known/mercure]
# The public URL of the Mercure hub, used by the browser to connect
#MERCURE_PUBLIC_URL=[http://192.168.xx.xx:80/.well-known/mercure]
# The secret used to sign the JWTs
#MERCURE_JWT_SECRET="!ChangeThisMercureHubJWTSecretKey!"
##< symfony/mercure-bundle ###
MERCURE_URL=http://localhost/.well-known/mercure
# The public URL of the Mercure hub, used by the browser to connect
MERCURE_PUBLIC_URL=http://localhost/.well-known/mercure
# The secret used to sign the JWTs
MERCURE_JWT_SECRET="!ChangeThisMercureHubJWTSecretKey!"
##< symfony/mercure-bundle ###

and this is the mercure config :

mercure:
    hubs:
        default:
            url: '%env(MERCURE_URL)%'
            public_url: '%env(MERCURE_PUBLIC_URL)%'
            jwt:
                secret: '%env(MERCURE_JWT_SECRET)%'
                publish: '*'

when i click on the mercure link for testing http://192.168.xx.xx:80/.well-known/mercure on a new tab is giving me a message missing topic ( which is logically normal) but it does not listen on my project and keep waiting for so long and i got a 200 response after a long time and i dont think that's working
note that i'm using a private ip adress on the server and all my configuration is working well on my local host
thanks for help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions