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

Laravel WebSocket SSL错误无法通过Pusher传递,自定义Handler无效求助

SSL WebSocket错误无法通过Pusher传递

我在使用带SSL的WebSocket服务,当SSL出现问题时,无法获取到具体的错误信息。排查后发现SecureServer.php文件中存在触发错误的代码,但这些错误无法通过Pusher传递到客户端。

当SSL证书和私钥有效时,系统运行完全正常,但我需要在SSL出现问题时,能将对应的错误信息展示给客户端。求帮忙实现让触发的错误信息通过Pusher传递。

版本信息

  • Laravel: 9.52.4
  • laravel-websockets: 1.13.2
  • react/socket: 1.12.0
  • pusher-js: 7.0.3

已尝试的方案

我创建了自定义WebSocketHandler,在onError()函数中尝试发送pusher:error事件,但该方案未生效:

public function onError(ConnectionInterface $connection, Exception $exception)
{
    if ($exception instanceof WebSocketException) {
        $connection->send(
            json_encode([
                "event" => "pusher:error",
                "data" => json_encode([
                    "socket_id" => $connection->socketId,
                    "activity_timeout" => 30,
                    "exception" => json_encode($exception->getPayload()),
                ]),
            ])
        );
    }
}

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.19 22:35:06