如何解决Laravel Pusher错误此事件的数据内容超出

发布于 2025-01-14 08:25:00 字数 1425 浏览 2 评论 0原文

我今天更新了 Laravel 9。之前,Pusher 在应用程序上运行良好。

现在,我总是收到以下错误:

推送错误:此事件的数据内容超出允许的最大值(10240 字节)

我没有更改内容。

我测试了使用给定的 supplier_id 更改内容,使用像“ee”这样的假 ID,并且没有任何限制。

在控制台日志中,我得到以下结果:

在此处输入图像描述

为什么即使后端出现错误,推送器仍能工作?

<?php

namespace App\Events\Kanban;

use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log;

class KanbanOrderCreatedEvent  implements ShouldBroadcast
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

    public $kanbanOrder;

    public function __construct($kanbanOrder)
    {
        $this->kanbanOrder = $kanbanOrder;
    }

    /**
     * Get the channels the event should broadcast on.
     *
     * @return \Illuminate\Broadcasting\Channel|array
     */
    public function broadcastOn()
    {
        return ['kanbanOrders.'.$this->kanbanOrder->network_supplier_id];
    }

    public function broadcastAs()
    {
        return 'kanbanOrderCreated';
    }

    public function broadcastWith()
    {
        return ['supplier_id' => $this->kanbanOrder->network_supplier_id];
    }

}

I did the update to Laravel 9 today. Before, Pusher worked well on the application.

Now, I receive always the following error:

Pusher error: The data content of this event exceeds the allowed maximum (10240 bytes)

I didn't change the content.

I tested to change the content with the given supplier_id, with a fake id like "ee" and without any restrictions.

In the console log, I have the following result:

enter image description here

Why does pusher work, even there is an error in the backend?

<?php

namespace App\Events\Kanban;

use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log;

class KanbanOrderCreatedEvent  implements ShouldBroadcast
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

    public $kanbanOrder;

    public function __construct($kanbanOrder)
    {
        $this->kanbanOrder = $kanbanOrder;
    }

    /**
     * Get the channels the event should broadcast on.
     *
     * @return \Illuminate\Broadcasting\Channel|array
     */
    public function broadcastOn()
    {
        return ['kanbanOrders.'.$this->kanbanOrder->network_supplier_id];
    }

    public function broadcastAs()
    {
        return 'kanbanOrderCreated';
    }

    public function broadcastWith()
    {
        return ['supplier_id' => $this->kanbanOrder->network_supplier_id];
    }

}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文