Comments (7)
I'm still intrigued to know why your requests are getting split up like that, but I've tested your PR and all looks good so going to recommend this gets merged. Thanks for digging into this one 👍
from reverb.
Are you sure you're running the latest version as we resolved a very similar issue a few weeks back: https://github.com/laravel/reverb/pull/87/files
from reverb.
Hi Joe, I'm using v1.0.0-beta9 which includes these updates.
I've sent a pull request where I believe there is an error:
https://github.com/laravel/reverb/blob/main/src/Servers/Reverb/Http/Request.php#L36
if ($connection->bufferLength() < $contentLength[0] ?? 0)
should be
if ($request->getBody()->getSize() < $contentLength[0] ?? 0)
Content-Length should be compared to the length of the body only since the length of the buffer also includes the headers.
After this, the incomplete requests are rejected as null
. The behaviour seems to work for me because the connection is held open and the missing data is appended to the buffer (at least, that's how I think it works) after which the request gets through and is broadcast
15:07:41.6876 Request Content-Length> 362
15:07:41.6876 Request Body> 0
-
15:07:41.6878 Request Content-Length> 362
15:07:41.6878 Request Body> 362
from reverb.
@stephenfrank Your assumption is correct about how the buffer will continue to be filled until the end of body symbol is received.
Your logic makes sense to me, but I'm not sure how this is the first time it has been raised.
Assuming the values in your last messages are from log statements, could you also include the value of $connection->bufferLength()
?
from reverb.
I agree, seems like something that would have come up.
Here is the same logging with the buffers length:
1715094296.4642 | Connection Buffer> 948
1715094296.4642 | Request Content-Length> 362
1715094296.4642 | Request Body> 362
1715094297.982 | ->
1715094297.982 | Connection Buffer> 586
1715094297.982 | Request Content-Length> 362
1715094297.982 | Request Body> 0
1715094297.9822 | ->
1715094297.9822 | Connection Buffer> 948
1715094297.9822 | Request Content-Length> 362
1715094297.9822 | Request Body> 362
Running in Request.php
public static function from(string $message, Connection $connection, int $maxRequestSize): ?RequestInterface
{
$connection->appendToBuffer($message);
if ($connection->bufferLength() > $maxRequestSize) {
throw new OverflowException('Maximum HTTP buffer size of '.$maxRequestSize.'exceeded.');
}
if (static::isEndOfMessage($buffer = $connection->buffer())) {
$request = Message::parseRequest($buffer);
$t = microtime(true);
echo "$t | ->\n";
echo "$t | Connection Buffer> {$connection->bufferLength()}\n";
echo "$t | Request Content-Length> {$request->getHeader('Content-Length')[0]}\n";
echo "$t | Request Body> {$request->getBody()->getSize()}\n";
if (! $contentLength = $request->getHeader('Content-Length')) {
return $request;
}
if ($request->getBody()->getSize() < $contentLength[0] ?? 0) {
return null;
}
$connection->clearBuffer();
return $request;
}
return null;
}
Running on Docker / Macbook / ARM64:
php -v
PHP 8.2.9 (cli) (built: Aug 29 2023 10:48:25) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.9, Copyright (c) Zend Technologies
with Zend OPcache v8.2.9, Copyright (c), by Zend Technologies
with Xdebug v3.2.1, Copyright (c) 2002-2023, by Derick Rethans
from reverb.
Do the second and third logs comprise a single request?
from reverb.
Yes, sorry maybe I could explain better...
Request 1) $connection->on('data'
receives header and body in a single chunk
1715094296.4642 | Connection Buffer> 948
1715094296.4642 | Request Content-Length> 362
1715094296.4642 | Request Body> 362
Request 2) $connection->on('data'
is fired twice and receives header in first chunk and body in the second chunk
1715094297.982 | ->
1715094297.982 | Connection Buffer> 586
1715094297.982 | Request Content-Length> 362
1715094297.982 | Request Body> 0
1715094297.9822 | ->
1715094297.9822 | Connection Buffer> 948
1715094297.9822 | Request Content-Length> 362
1715094297.9822 | Request Body> 362
from reverb.
Related Issues (20)
- Reverb not sending any event to client HOT 11
- Event broadcasting wrongly serialize payload HOT 2
- I have issue in reverb broadcasting HOT 5
- Reverb with Self-Signed Certificate and Supervision as Queue Worker HOT 5
- I have issue in reverb broadcasting with Laravel Forge HOT 5
- Add backend listener for presence channel events to log user attendance HOT 11
- Backward compatibility. HOT 1
- Health check endpoint to support GKE deployment using GCE Ingress
- Laravel Reverb with Octane HOT 1
- Pusher error: Internal server error.. HOT 8
- could not find driver (Connection: mysql, SQL: select * from `cache` where `key` = laravel:reverb:restart limit 1) HOT 2
- redis is empty HOT 1
- Reverb on Subdomain can't initiate websocket server HOT 1
- Can we have a bidirectional connection with reverb?? from client to server and from server to client?? HOT 4
- In listener broadcast back job hanging on CURL Error HOT 20
- When activated for more than a day, it connects very slowly HOT 12
- Reverb not connectable locally via WebSocket (404) HOT 5
- Echo not subscribing to Reverb on production (works fine on my local) HOT 1
- Bubble up Exceptions HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from reverb.