Websocket icon indicating copy to clipboard operation
Websocket copied to clipboard

Set header buffer size

Open Pierozi opened this issue 9 years ago • 9 comments

Refer to issue #72

Today the library will take arbitrary first 2048 bytes of stream and send them to Http library. Until we design better interface on Hoa\Http we can still make the buffer size configurable.

Did we implement this parameter with Hoa\Zformat and array as argument of constructor ?

Pierozi avatar Aug 12 '16 10:08 Pierozi

I guess this is better to increase it to 4092. If it fixes the issue in #72, then this is good enough, and then we will address this issue in Hoa\Http. This is the cleaner solution. Thoughts?

Hywan avatar Aug 15 '16 07:08 Hywan

I don't know, @hhxsv5 use cookie encrypted, that depend of the encryption use. 2048 seems to me already big, even with huge Authorization token. Can we have consequences if we increase the value ? apart from memory footprint on variable.

Pierozi avatar Aug 15 '16 09:08 Pierozi

I think it's better to read stream until we get header "sec-websocket-key" or eof.

other websocket projects: https://github.com/Textalk/websocket-php/blob/master/lib/Server.php#L76 https://github.com/vakata/websocket/blob/master/src/Base.php#L96

hhxsv5 avatar Aug 16 '16 10:08 hhxsv5

Hi @hhxsv5, the question was not how parse the header, but have enough data. In your example, they dump the entries content of stream into local variable $request.

In our case, it is Hoa\Http responsible to parse header. But library do not accept yet stream as argument.

It is not acceptable for us to dump entire stream content, because it's a stream... we only want here extract header part.

There as two option :

  1. Increase value to 4096 or 8192 for sure to cover your long key.
  2. Wait until we refactor Hoa\Http with PSR-7

Pierozi avatar Sep 14 '16 22:09 Pierozi

Can we increase it to the maximum TCP frame size? 4096 is way too low for my needs. Thanks!

mmowbray avatar Sep 16 '16 16:09 mmowbray

I think we should really revamp the Hoa\Http library. However, a temporary non-breaking patch would be to increase it to 4096.

@Pierozi Could you just increase the size to 4096 in #74, without the addition of new methods. Thanks!

Hywan avatar Mar 24 '17 14:03 Hywan

@Hywan Ok I will do that, I also think it's for the best at this time.

Pierozi avatar Mar 31 '17 08:03 Pierozi

what ??? Not fixed yet... wasted hours looking for problems

zsp00 avatar Mar 18 '19 08:03 zsp00

@zhusipu Finally, I built the WebSocket server with Swoole.

hhxsv5 avatar Mar 18 '19 09:03 hhxsv5