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
相关产品推荐
相关产品推荐

