You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Symfony集成Mercure失败:无法发送Update请求求助

Mercure与Symfony互通配置问题

已尝试2天配置Mercure与Symfony项目实现互通,Mercure服务器部署在Nginx后的容器中,curl命令可正常发送请求:

curl -d 'topic=https://example.com/books/1' -d 'data={"foo": "updated value"}' -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJtZXJjdXJlIjp7InB1Ymxpc2giOlsiKiJdfX0.5zgB1OBh7fwae_97lhU-3u59c2z0Q0vknvN3zuP7yfs' -X POST -k https://10.145.90.xxx/mercure

返回结果:

urn:uuid:d6dcf0b5-9c87-4ef0-9400-e9496bbe71b6

Symfony项目的.env配置:

MERCURE_PUBLIC_URL=https://10.145.90.xxx/mercure
MERCURE_URL=https://10.145.90.xxx/mercure
MERCURE_JWT_SECRET="2gtdpkx8AzLL0FBsCBmKEa66qIrccMW6LeRX"

Mercure配置(默认):

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

框架已配置跳过证书校验:

framework:
    ...
    http_client:
        default_options:
            verify_peer: false

curl可正常收发数据,但Symfony中发送Update时报错:

"Handling \"Symfony\\Component\\Mercure\\Update\" failed: Failed to send an update."

Update构建代码:

$update = new Update(
    $entity->mercureTopic(),
    json_encode([
        'user' => $user === null ? 'UNDEFINED' : $user->getUserIdentifier(),
        'action' => 'version_incremented',
        'orderId' => $entity->getId()
    ])
);
$this->getMessageBus()->dispatch($update);

请问可能遗漏了什么配置?如何查看更详细的错误信息?


内容的提问来源于stack exchange,提问作者Fpasquer

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.20 08:57:10