404 Error with Mercure public link #60119
-
I use Symfony UX and i followed this to implement a chat using mercure in my app: https://symfony.com/bundles/ux-turbo/current/index.html#sending-async-changes-using-mercure-a-chat. My config: ###> symfony/mercure-bundle ###
# The URL of the Mercure hub, used by the app to publish updates (can be a local URL)
MERCURE_URL=https://127.0.0.1:8800/.well-known/mercure
MERCURE_PUBLIC_URL=https://127.0.0.1:8800/.well-known/mercure
MERCURE_JWT_SECRET="sIsF/hvg/Z4Yu0N9VNboDc1Aro1i2Pondk1FkHFsUr8="
###< symfony/mercure-bundle ### But i have a 404 error when i open the mercure link: https://127.0.0.1:8800/.well-known/mercure. mercure:
image: dunglas/mercure
restart: unless-stopped
environment:
# Uncomment the following line to disable HTTPS,
#SERVER_NAME: ':80'
MERCURE_PUBLISHER_JWT_KEY: 'sIsF/hvg/Z4Yu0N9VNboDc1Aro1i2Pondk1FkHFsUr8='
MERCURE_SUBSCRIBER_JWT_KEY: 'sIsF/hvg/Z4Yu0N9VNboDc1Aro1i2Pondk1FkHFsUr8='
# Set the URL of your Symfony project (without trailing slash!) as value of the cors_origins directive
MERCURE_EXTRA_DIRECTIVES: |
cors_origins https://127.0.0.1:8800
# 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 ### And my docker logs: 2025-04-01 12:10:23 mercure-1 | {"level":"info","ts":1743502223.484836,"msg":"GOMEMLIMIT is updated","package":"github.com/KimMachineGun/automemlimit/memlimit","GOMEMLIMIT":3622020710,"previous":9223372036854775807}
2025-04-01 12:10:23 mercure-1 | {"level":"info","ts":1743502223.4874907,"msg":"using config from file","file":"/etc/caddy/dev.Caddyfile"}
2025-04-01 12:10:23 mercure-1 | {"level":"info","ts":1743502223.4901364,"msg":"adapted config to JSON","adapter":"caddyfile"}
2025-04-01 12:10:23 mercure-1 | {"level":"warn","ts":1743502223.4901993,"msg":"Caddyfile input is not formatted; run 'caddy fmt --overwrite' to fix inconsistencies","adapter":"caddyfile","file":"/etc/caddy/dev.Caddyfile","line":6}
2025-04-01 12:10:23 mercure-1 | {"level":"info","ts":1743502223.495413,"logger":"admin","msg":"admin endpoint started","address":"localhost:2019","enforce_origin":false,"origins":["//[::1]:2019","//127.0.0.1:2019","//localhost:2019"]}
2025-04-01 12:10:23 mercure-1 | {"level":"info","ts":1743502223.4956708,"logger":"http.auto_https","msg":"server is listening only on the HTTPS port but has no TLS connection policies; adding one to enable TLS","server_name":"srv0","https_port":443}
2025-04-01 12:10:23 mercure-1 | {"level":"info","ts":1743502223.4957626,"logger":"http.auto_https","msg":"enabling automatic HTTP->HTTPS redirects","server_name":"srv0"}
2025-04-01 12:10:23 mercure-1 | {"level":"info","ts":1743502223.4960418,"logger":"tls.cache.maintenance","msg":"started background certificate maintenance","cache":"0xc00075a480"}
2025-04-01 12:10:23 mercure-1 | {"level":"warn","ts":1743502223.5079937,"logger":"pki.ca.local","msg":"installing root certificate (you might be prompted for password)","path":"storage:pki/authorities/local/root.crt"}
2025-04-01 12:10:23 mercure-1 | {"level":"info","ts":1743502223.5112717,"msg":"warning: \"certutil\" is not available, install \"certutil\" with \"apt install libnss3-tools\" or \"yum install nss-tools\" and try again"}
2025-04-01 12:10:23 mercure-1 | {"level":"info","ts":1743502223.5113342,"msg":"define JAVA_HOME environment variable to use the Java trust"}
2025-04-01 12:10:23 mercure-1 | {"level":"info","ts":1743502223.5152311,"logger":"tls","msg":"storage cleaning happened too recently; skipping for now","storage":"FileStorage:/data/caddy","instance":"2b849cd0-fd72-411b-b196-9eb643d788ec","try_again":1743588623.5152261,"try_again_in":86399.9999993}
2025-04-01 12:10:23 mercure-1 | {"level":"info","ts":1743502223.515562,"logger":"tls","msg":"finished cleaning storage units"}
2025-04-01 12:10:23 mercure-1 | {"level":"info","ts":1743502223.6227891,"msg":"certificate installed properly in linux trusts"}
2025-04-01 12:10:23 mercure-1 | {"level":"info","ts":1743502223.624046,"logger":"http","msg":"enabling HTTP/3 listener","addr":":443"}
2025-04-01 12:10:23 mercure-1 | {"level":"info","ts":1743502223.6242604,"msg":"failed to sufficiently increase receive buffer size (was: 208 kiB, wanted: 7168 kiB, got: 416 kiB). See https://github.com/quic-go/quic-go/wiki/UDP-Buffer-Sizes for details."}
2025-04-01 12:10:23 mercure-1 | {"level":"info","ts":1743502223.6245792,"logger":"http.log","msg":"server running","name":"srv0","protocols":["h1","h2","h3"]}
2025-04-01 12:10:23 mercure-1 | {"level":"warn","ts":1743502223.624839,"logger":"http","msg":"HTTP/2 skipped because it requires TLS","network":"tcp","addr":":80"}
2025-04-01 12:10:23 mercure-1 | {"level":"warn","ts":1743502223.6249208,"logger":"http","msg":"HTTP/3 skipped because it requires TLS","network":"tcp","addr":":80"}
2025-04-01 12:10:23 mercure-1 | {"level":"info","ts":1743502223.6249309,"logger":"http.log","msg":"server running","name":"remaining_auto_https_redirects","protocols":["h1","h2","h3"]}
2025-04-01 12:10:23 mercure-1 | {"level":"info","ts":1743502223.6249385,"logger":"http","msg":"enabling automatic TLS certificate management","domains":["localhost"]}
2025-04-01 12:10:23 mercure-1 | {"level":"info","ts":1743502223.6271732,"msg":"autosaved config (load with --resume flag)","file":"/config/caddy/autosave.json"} My project is on https://127.0.0.1:8800, i run it with |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 10 replies
-
I think the public URL is supposed to be the hub’s, not your app’s. Don’t you have a |
Beta Was this translation helpful? Give feedback.
-
@Asmitta-01 But can you access the URL in HTTPS? |
Beta Was this translation helpful? Give feedback.
I reverted back all my changes then followed this course: https://symfonycasts.com/screencast/turbo/mercure (Chapter 47-52).
It works now.
Comparing changes, it seems that i should have juste uncomment the
#SERVER_NAME: ':80'
line in the compose.yaml. And the mercure port is random, so each time if i want to access i should do tryhttp://127.0.0.1:<random_port>/.well-known/mercure
. We can get the port with the command: