kakserpom / phpdaemon

Asynchronous server-side framework for network applications implemented in PHP using libevent
http://daemon.io/
GNU Lesser General Public License v3.0
1.53k stars 232 forks source link

#280 Websocket server drop connection on attempting to receive text (… #281

Closed kuai6 closed 7 years ago

kuai6 commented 7 years ago

…JSON) message more than 65535 bytes

In attempt to accept the message splitted into fragments the server does not respond to the requests. The reason - incorrect watermark range on the "EventBufferEvent" input buffer.

Also we have found out that the current WS protocol implementation doesn't correspond to RFC, namely section 4.4 Fragmentation (https://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-10#section-4.4)

According to RFC:

A fragmented message consists of a single frame with the FIN bit clear and an opcode other than 0, followed by zero or more frames with the FIN bit clear and the opcode set to 0, and terminated by a single frame with the FIN bit set and an opcode of 0.

The current implementation does not save first frame opcode value into variable.

This PR solves both problems described above.