[{"data":1,"prerenderedAt":29},["ShallowReactive",2],{"$f1w4ffdsbaj11c":3,"$f18bx9hhf8rh83":21},{"content":4,"canonicalPath":5,"package":6,"version":20},"# Running the WebSocket Server\n\nThe websocket server is run with the `babdev:websocket-server:run` command:\n\n```bash\nphp bin\u002Fconsole babdev:websocket-server:run\n```\n\nBy default, the server listens for connections on the URI from the `babdev_websocket.server.uri` configuration (see the [installation documentation](\u002Fopen-source\u002Fpackages\u002Fwebsocketbundle\u002Fdocs\u002F1.x\u002Finstallation)), which can be overridden with the command's argument:\n\n```bash\nphp bin\u002Fconsole babdev:websocket-server:run 127.0.0.1:8081\n```\n\nThe command runs until the server is stopped. In production, it is recommended to run it with a process manager (such as Supervisor or systemd) which restarts the server if it exits, as an unexpected error stops the server with a non-zero exit code.\n\n## Stopping the Server\n\nThe server is stopped when the process receives a `SIGINT` (for example, when pressing Ctrl+C), `SIGTERM` (for example, when a container is stopped), or `SIGQUIT` signal. Handling these signals requires the `pcntl` PHP extension.\n\nWhen a signal is received, the server shuts down gracefully: it stops accepting new connections, sends connected clients a \"1001 Going Away\" close frame, and waits for the open connections to close. Connections which have not closed when the shutdown timeout expires are forcibly closed. A second signal stops the server immediately.\n\n```yaml\n# config\u002Fpackages\u002Fbabdev_websocket.yaml\nbabdev_websocket:\n  server:\n    # The time, in seconds, to wait for connections to close, 5 seconds by default\n    shutdown_timeout: 10\n```\n\nSetting the shutdown timeout to `null` stops the server immediately without waiting for connections to close.\n\nThe `BabDev\\WebSocketBundle\\Event\\AfterServerClosed` event is dispatched once the server has stopped accepting new connections, and the `BabDev\\WebSocketBundle\\Event\\AfterLoopStopped` event is dispatched once the server has stopped (see the [events documentation](\u002Fopen-source\u002Fpackages\u002Fwebsocketbundle\u002Fdocs\u002F1.x\u002Fevents)).\n\n## Managing Connections\n\nThe bundle provides several options to protect the server from clients which are slow or no longer responding.\n\n```yaml\n# config\u002Fpackages\u002Fbabdev_websocket.yaml\nbabdev_websocket:\n  server:\n    # The time, in seconds, a client has to send its HTTP request, 10 seconds by default\n    request_timeout: 10\n    # The interval, in seconds, at which connected clients are pinged, disabled by default\n    keepalive: 30\n    # The number of bytes which can be written to a client after its write buffer is full, 1 MiB by default\n    write_buffer_limit: 1048576\n```\n\n- `request_timeout` closes connections which do not send a complete HTTP request in time with a \"408 Request Timeout\" response, including clients which send their request slowly\n- `keepalive` pings connected clients at the given interval, and closes connections which have not responded to the previous ping\n- `write_buffer_limit` closes the connection to a client which is not reading the data sent to it once this much data has been written to the connection after its write buffer is full, preventing it from exhausting the server's memory\n\nEach of these options can be disabled by setting it to `null`.\n\nThe size of the messages received from clients can also be limited, see the [securing connections documentation](\u002Fopen-source\u002Fpackages\u002Fwebsocketbundle\u002Fdocs\u002F1.x\u002Fsecuring-connections).\n\n## WAMP Protocol Options\n\n```yaml\n# config\u002Fpackages\u002Fbabdev_websocket.yaml\nbabdev_websocket:\n  server:\n    # Whether clients must request the \"wamp\" sub-protocol, enabled by default\n    strict_sub_protocol_check: true\n    # The maximum number of CURIE prefixes a client can register for its connection, 100 by default\n    max_prefixes: 100\n```\n\n- `strict_sub_protocol_check` rejects clients which do not request the `wamp` sub-protocol in their `Sec-WebSocket-Protocol` header with a \"426 Upgrade Required\" response; disabling it allows these clients to connect\n- `max_prefixes` limits the number of prefixes a client can register with the WAMP \"PREFIX\" message\n\n## Using Environment Variables\n\nThe server options can be set with environment variables. As with other numeric configuration in Symfony, numeric options require a typed environment variable processor:\n\n```yaml\n# config\u002Fpackages\u002Fbabdev_websocket.yaml\nbabdev_websocket:\n  server:\n    request_timeout: '%env(float:WEBSOCKET_REQUEST_TIMEOUT)%'\n    write_buffer_limit: '%env(int:WEBSOCKET_WRITE_BUFFER_LIMIT)%'\n```\n","\u002Fopen-source\u002Fpackages\u002Fwebsocketbundle\u002Fdocs\u002F1.x\u002Frunning-the-server",{"name":7,"slug":8,"description":9,"github":10,"packagistName":12,"packageType":13,"hasDocumentation":14,"supported":14,"visible":14,"versions":15},"WebSocketBundle","websocketbundle","Bundle integrating the WebSocket Server library with Symfony",{"owner":11,"repo":7},"BabDev","babdev\u002Fwebsocket-bundle","symfony-bundle",true,[16],{"version":17,"gitBranch":18,"released":19},"1.x","0.1",false,{"version":17,"gitBranch":18,"released":19},{"content":22,"canonicalPath":23,"package":24,"version":28},"- [Introduction](\u002Fopen-source\u002Fpackages\u002Fwebsocketbundle\u002Fdocs\u002F1.x\u002Fintro)\n- [Installation & Setup](\u002Fopen-source\u002Fpackages\u002Fwebsocketbundle\u002Fdocs\u002F1.x\u002Finstallation)\n- [Authentication](\u002Fopen-source\u002Fpackages\u002Fwebsocketbundle\u002Fdocs\u002F1.x\u002Fauthentication)\n- [Default Configuration](\u002Fopen-source\u002Fpackages\u002Fwebsocketbundle\u002Fdocs\u002F1.x\u002Fdefault-configuration)\n- [Events](\u002Fopen-source\u002Fpackages\u002Fwebsocketbundle\u002Fdocs\u002F1.x\u002Fevents)\n- [Managing Middleware](\u002Fopen-source\u002Fpackages\u002Fwebsocketbundle\u002Fdocs\u002F1.x\u002Fmanaging-middleware)\n- [Periodic Manager](\u002Fopen-source\u002Fpackages\u002Fwebsocketbundle\u002Fdocs\u002F1.x\u002Fperiodic-manager)\n- [Registering Message Handlers](\u002Fopen-source\u002Fpackages\u002Fwebsocketbundle\u002Fdocs\u002F1.x\u002Fregistering-message-handlers)\n- [Running the WebSocket Server](\u002Fopen-source\u002Fpackages\u002Fwebsocketbundle\u002Fdocs\u002F1.x\u002Frunning-the-server)\n- [Securing Connections](\u002Fopen-source\u002Fpackages\u002Fwebsocketbundle\u002Fdocs\u002F1.x\u002Fsecuring-connections)\n","\u002Fopen-source\u002Fpackages\u002Fwebsocketbundle\u002Fdocs\u002F1.x\u002Findex",{"name":7,"slug":8,"description":9,"github":25,"packagistName":12,"packageType":13,"hasDocumentation":14,"supported":14,"visible":14,"versions":26},{"owner":11,"repo":7},[27],{"version":17,"gitBranch":18,"released":19},{"version":17,"gitBranch":18,"released":19},1795189058677]