Hi,
I use PHP 8.3, Symfony 7.1 and Mercure in my project and I have a problem.
My docker run perfectly and the website work too, but when I want to use Mercure (Mercure is an open protocol designed from the ground up to publish updates from server to clients).
When I want to subscribe to a topic the page loads endlessly but in local I don’t have a problem.
Are there any known issues with the eventSource on IDX?
My URL for the test is https://3000-{idx_url}/.well-known/mercure?topic=log_debug
and in JS I just try to subscribe like that, but I have the same problem :
initEventSource() {
// this.data.get('mercure') is my mercure url like above
this.eventSource = new EventSource(this.data.get('mercure'));
this.eventSource.onmessage = (e) => this.onMercureMessage(e);
}
My docker-compose.yaml I have that config for mercure :
###> symfony/mercure-bundle ###
mercure:
image: dunglas/mercure
restart: unless-stopped
container_name: symfony_mercure
networks:
- symfony
environment:
# Uncomment the following line to disable HTTPS,
SERVER_NAME: ':80'
MERCURE_PUBLISHER_JWT_KEY: '${MERCURE_JWT_SECRET}'
MERCURE_SUBSCRIBER_JWT_KEY: '${MERCURE_JWT_SECRET}'
# Set the URL of your Symfony project (without trailing slash!) as value of the cors_origins directive
MERCURE_EXTRA_DIRECTIVES: |-
cors_origins "*"
anonymous
# Comment the following line to disable the development mode
command: /usr/bin/caddy run --config /etc/caddy/dev.Caddyfile
healthcheck:
test: ["CMD", "curl", "-f", "https://localhost/healthz"]
timeout: 5s
retries: 5
start_period: 60s
volumes:
- mercure_data:/data
- mercure_config:/config
###< symfony/mercure-bundle ###
I use a nginx server with this configuration :
events {
}
http {
server {
listen 80;
server_name localhost;
root /var/www/symfony/public;
location / {
try_files $uri /index.php$is_args$args;
}
location ~ \.php$ {
fastcgi_pass symfony_php:9000;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
location /.well-known/mercure {
proxy_pass http://symfony_mercure:80; # Modifié pour utiliser le port 80
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # Ajout de ce header pour passer l'IP d'origine
proxy_set_header X-Forwarded-Proto $scheme; # Ajout de ce header pour passer le protocole (HTTP ou HTTPS)
}
}
}
And in my .env.local in Symfony I have the next url :
MERCURE_PUBLIC_URL=http://localhost:3000/.well-known/mercure
This URL create a good url for mercure in IDX, I know it because if I go to this page
https://3000-{idx_url}/.well-known/mercure
I have the next message : Missing “topic” parameter.
But when I put my topic, the page loads endlessly and in the network tab EventStream never appears.
Thank you for your help if you have any ideas.