Ratchet Websockets PHP中不显示错误

时间:2019-10-02 18:44:17

标签: php laravel artisan ratchet

我有一个Laravel应用程序,并且正在使用PHP artisan命令启动Ratchet Websocket服务器。

我注意到,如果出现错误,则不会在Laravel的日志或stderr中都显示该错误。为了重现这一点,我有如下内容:

function onMessage(ConnectionInterface $conn, $msg) {
     Log::info("Debug " . $variable_that_is_not_defined);
}

我还尝试在此日志中添加try catch,并且未调用catch块。每当我收到来自客户端的消息时,连接都会关闭,但没有看到任何错误。

这是Laravel命令:

class WebSocketServer extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'command:websocket';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $server = IoServer::factory(
            new HttpServer(
                new WsServer(
                    new WebSocketController()
                )
            ),
            8090
        );
        $server->run();
    }
}

我正在使用以下命令启动服务器:

php artisan command:websocket

0 个答案:

没有答案