On Tue, 28 Jan 2020 at 14:26, Thomas Hruska <thru...@cubiclesoft.com> wrote:

> People tend to write WebSocket servers in NodeJS partly because they
> don't realize that PHP can already do the same.  Example:
>
> https://github.com/cubiclesoft/php-drc


I didn't realize, so this is a great share. Thanks.


> WebSocket generally introduces network and processing overhead - HTTP
> headers and parsing for setup + framing protocol handling.  In many
> cases, a simpler "JSON blob per newline" approach works just as well (if
> not better) and can afford better isolation and performance models (i.e.
> not everything has to be WebSocket).  There are plenty of flaws inherent
> to the design of the WebSocket protocol itself (some are
> security-oriented) and so anything built on it shares those flaws.
>

This critique of WebSockets sounds similar to that of https://mercure.rocks/,
which uses HTTP/2 and Server-Sent Events instead of WebSockets.

I'm interested in WebSockets because I've been following the development of
Phoenix LiveView [1] for the last 13 months. Something similar in PHP would
be awesome (though the statelessness of PHP will complicate matters), but
when I looked at Swoole et al they wouldn't work with my existing
framework-based code. An approach that avoids rewriting, like some form of
built-in support in the language would be good for this alone.

Peter

1.
https://dockyard.com/blog/2018/12/12/phoenix-liveview-interactive-real-time-apps-no-need-to-write-javascript

Reply via email to