reverb: Dont respect max_message_size

Reverb Version

@beta

Laravel Version

11.0

PHP Version

8.3.3

Description

     [
                'key' => 'test',
                'secret' => 'test',
                'app_id' => 12347,
                'options' => [
                    'host' => '0.0.0.0',
                    'port' => 8080,
                    'scheme' => 'http',
                    'useTLS' => false,
                ],
                'allowed_origins' => ['*'],
                'ping_interval' => 60,
                'max_message_size' => 2500000,
            ],

Illuminate\Broadcasting\BroadcastException Pusher error: Payload too large…

Steps To Reproduce

  1. install latest laravel
  2. intall latest reverb
  3. set max_message_size 2500000 (this is 2.5 Megabytes ??)
  4. if sent > 11kb payload. get error

About this issue

  • Original URL
  • State: closed
  • Created 4 months ago
  • Reactions: 1
  • Comments: 45 (18 by maintainers)

Most upvoted comments

@tarreislam Just had a gut feeling when I saw one comment stating the payload was invalid.

@samuelrac Glad that’s working, but need to do some further testing to make sure the change hasn’t impacted anything else, so probably not until next week.

@tarreislam @mttzzz Could you give this branch another test: https://github.com/laravel/reverb/pull/87

I think I cracked it now by fixing the code which waits for the complete body of the HTTP request.

@mttzzz Joe will have a look when he has time.

@mttzzz I have this running on a server now with 500 connections each receiving a broadcast using the payload you provided once per second and I’ve not seen the error appear in my log.

Thanks! The event is being broadcast from Laravel when you see the error?

Yes, laravel 10

How large is the string you are sending?

The string I’m sending is 53.5 KB apart from the other data that comes with it that refers to the socket. However, I need it to hold up to 100KB (without considering the data that comes with the socket) When I send a very large string, sometimes it gives an Internal Server Error due to the validator error expecting an array and json_decode returning NULL

After adjusting the MAX_SIZE constant to 200,000 manually, the issues related to ‘413 Payload Too Large’ errors have ceased. However, intermittent occurrences of ‘500 Internal Server Error’ have been observed, leading to occasional crashes of the system’s reverb mechanism.

Yeah I have been debugging that 500 internal server error too and I found it was cuRL getting “empty response” from server, so probably something in reverb.

The devs here are really experienced and will probably get this done sooner or later 😃

The string I’m sending is 53.5 KB apart from the other data that comes with it that refers to the socket

I agree with this, even if the norm is to send smaller payloads it does not hurt to support larger payloads, even 2 MB should be OK in 2024.

BTW here is how I am handling the error in production. Just until we can adjust the size ourselves 😆. Not recommended

image

How large is the string you are sending?

The string I’m sending is 53.5 KB apart from the other data that comes with it that refers to the socket. However, I need it to hold up to 100KB (without considering the data that comes with the socket)

When I send a very large string, sometimes it gives an Internal Server Error due to the validator error expecting an array and json_decode returning NULL

@tarreislam we’re releasing pretty ad-hoc at the moment, but will eventually fall into the weekly release cycle.

You’re right, this is hard-coded at the HTTP request layer and dynamic and the WebSocket message layer. I will get a fix up for this as soon as I can.