Symfony 3 WebSocketBundle PdoSessionHandler

How I install WebSocketBundle:

config.yml

gos_web_socket:
server:
    port: 8080
    host: localhost
client:
    firewall: main
    session_handler: session.handler.pdo
shared_config: true

And what is my services.yml :

services:
    session.handler.pdo:
        class: Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler
        public: false
        arguments:
            - 'mysql:host=%database_host%;dbname=%database_name%'
            - { db_username: '%database_user%', db_password: '%database_password%' }

I can start the server successfully in the console using php bin / console gos: websocket: server. But a fatal error is displayed in the terminal as soon as I try to connect to the server using a web browser:

console

C:\xampp\htdocs>php bin/console gos:websocket:server
[2017-02-18 10:38:13] websocket.INFO: Starting web socket
[2017-02-18 10:38:13] websocket.INFO: Launching Ratchet on localhost:8080 PID: 26568
PHP Fatal error:  Call to a member function beginTransaction() on null in C:\xampp\htdocs\vendor\symfony\symfony\src\Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler.php on line 439

Fatal error: Call to a member function beginTransaction() on null in C:\xampp\htdocs\vendor\symfony\symfony\src\Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler.php on line 439
[2017-02-18 10:38:16] php.CRITICAL: Fatal Error: Call to a member function beginTransaction() on null {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalErrorException(code: 0): Error: Call to a member function beginTransaction() on null at C:\\xampp\\htdocs\\vendor\\symfony\\symfony\\src\\Symfony\\Component\\HttpFoundation\\Session\\Storage\\Handler\\PdoSessionHandler.php:439)"}


  [Symfony\Component\Debug\Exception\FatalErrorException]
  Error: Call to a member function beginTransaction() on null

What am I doing wrong?

+4
source share

Source: https://habr.com/ru/post/1670155/


All Articles