JDare / ClankBundle

A Symfony2 Bundle for use with Ratchet WebSocket Server
MIT License
131 stars 31 forks source link

PDO Session Handler service is non-existent #44

Open ghost opened 9 years ago

ghost commented 9 years ago

I have set up the ClankBundle. I want to initialize session management so, I can have session object attached to the connections. I did what was suggested in the documentation. Added a service, attached it to framework session and clank handler. But when I run, php app/console clank:server it throws an error:

untitled

My services.yml file:

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

        kernel.listener.clank.client_event:
            class: Acme\ChatBundle\EventListener\AcmeClientEventListener
            tags:
                - { name: kernel.event_listener, event: clank.client.connected, method: onClientConnect }
                - { name: kernel.event_listener, event: clank.client.disconnected, method: onClientDisconnect }
                - { name: kernel.event_listener, event: clank.client.error, method: onClientError }

My config.yml file:

    imports:
        - { resource: parameters.yml }
        - { resource: security.yml }
        - { resource: services.yml }

    # Put parameters here that don't need to change on each machine where the app is deployed
    # http://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
    parameters:
        locale: en

    framework:
        #esi:             ~
        #translator:      { fallbacks: ["%locale%"] }
        secret:          "%secret%"
        router:
            resource: "%kernel.root_dir%/config/routing.yml"
            strict_requirements: ~
        form:            ~
        csrf_protection: ~
        validation:      { enable_annotations: true }
        #serializer:      { enable_annotations: true }
        templating:
            engines: ['twig']
            #assets_version: SomeVersionScheme
        default_locale:  "%locale%"
        trusted_hosts:   ~
        trusted_proxies: ~
        session:
            handler_id: session.handler.pdo

        http_method_override: true

    # Twig Configuration
    twig:
        debug:            "%kernel.debug%"
        strict_variables: "%kernel.debug%"

    # Assetic Configuration
    assetic:
        debug:          "%kernel.debug%"
        use_controller: false
        bundles:        [ JDareClankBundle ]
        #java: /usr/bin/java
        filters:
            cssrewrite: ~
            #closure:
            #    jar: "%kernel.root_dir%/Resources/java/compiler.jar"
            #yui_css:
            #    jar: "%kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar"

    # Doctrine Configuration
    doctrine:
        dbal:
            driver:   pdo_mysql
            host:     "%database_host%"
            port:     "%database_port%"
            dbname:   "%database_name%"
            user:     "%database_user%"
            password: "%database_password%"
            charset:  UTF8
            # if using pdo_sqlite as your database driver:
            #   1. add the path in parameters.yml
            #     e.g. database_path: "%kernel.root_dir%/data/data.db3"
            #   2. Uncomment database_path in parameters.yml.dist
            #   3. Uncomment next line:
            #     path:     "%database_path%"

        orm:
            auto_generate_proxy_classes: "%kernel.debug%"
            naming_strategy: doctrine.orm.naming_strategy.underscore
            auto_mapping: true

    # Swiftmailer Configuration
    swiftmailer:
        transport: "%mailer_transport%"
        host:      "%mailer_host%"
        username:  "%mailer_user%"
        password:  "%mailer_password%"
        spool:     { type: memory }
    clank:
        web_socket_server:
            port: 8080        #The port the socket server will listen on
            host: 127.0.0.1   #(optional) The host ip to bind to
        session_handler: session.handler.pdo
        topic:
            -
                name: "acme" #Important! this is the topic namespace used to match to this service!
                service: "acme_topic"

It is to be noted that the session handler works fine with in-browser app. It sets and gets session as expected. It is also reflected by changes in the table.

yescardmen commented 9 years ago

I've got the same problem, have you find a solution?

jjsaunier commented 9 years ago

This is not the same bundle but the configuration of session handler is the same

https://github.com/GeniusesOfSymfony/WebSocketBundle/blob/master/Resources/docs/SessionSetup.md#symfony-pdo-session-handler

yescardmen commented 9 years ago

Thanks a lot, working like a charm.

FabriceAbbey commented 8 years ago

Any luck with this issue I tried the configuration from https://github.com/GeniusesOfSymfony/WebSocketBundle/blob/master/Resources/docs/SessionSetup.md#symfony-pdo-session-handler and it is not working either. Can someone help me ? Thanks