hoaproject / Websocket

The Hoa\Websocket library.
https://hoa-project.net/
422 stars 75 forks source link

Set header buffer size #73

Open Pierozi opened 8 years ago

Pierozi commented 8 years ago

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 ?

Hywan commented 8 years ago

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?

Pierozi commented 8 years ago

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.

hhxsv5 commented 8 years ago

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

Pierozi commented 8 years ago

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
mmowbray commented 8 years ago

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

Hywan commented 7 years ago

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!

Pierozi commented 7 years ago

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

zsp00 commented 5 years ago

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

hhxsv5 commented 5 years ago

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