Menu

1 / 2

wsrv 1.1: Laravel Echo on a C++ WebSocket daemon

DEV Community: laravel·Dimath Jayasinghe·3 days ago
#9NDmwmts
#devtolaravel#devto#dev#wsrv#echo
Long article (1302 words) — no AI summary yet.
Reading 0:00
15s threshold

A WebSocket server that your PHP application talks to over a socket, now with Laravel Echo support, and an honest list of what was checked and what was not.

What wsrv is

PHP's usual process-per-request model is a poor fit for holding thousands of open sockets. wsrv puts the sockets somewhere else. wsrvd is a daemon written in C++23, a from-scratch implementation of RFC 6455 with no third-party WebSocket library, under the Apache-2.0 license. It owns the browser connections. Your PHP code connects to it over a Unix socket (or, since 1.1, over TCP with a generated token) and only reacts to events: a browser asked to connect, a message arrived, a connection closed.

docker run -d --name wsrvd -p 8080:8080 \ -v wsrv-ipc:/run/wsrv \ -e WSRVD_ALLOW_ORIGIN = https://app.example.com \ -e WSRVD_BROKER = true \ dimathjayasinghe/wsrvd:1.1.0

Enter fullscreen mode

Exit fullscreen mode

$worker = new Wsrv \ Worker ( Wsrv \ Client :: connect ( '/run/wsrv/ipc.sock' ) ) ; $worker -> on ( 'message' , fn ( $conn , $data )…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.