Git Product home page Git Product logo

Comments (13)

jjsaunier avatar jjsaunier commented on June 3, 2024

Have you try to clear your browser cookie ?

from websocketbundle.

faheem00 avatar faheem00 commented on June 3, 2024

Yes I did, but I do not see the relevance between this particular problem and cookies, because every time I try to clear cache using php app/console cache:clear command, the same error occurs.

This procedure was valid for Symfony 2.5, at 2.6 they made change which allows for passing dsn as parameter in pdo session handler, and for some reason when I try to pass the PDO class to the handler, it tries to serialize and pass the instance, so I think the problem lies there. It would be best if you can come up with a solution which will allow us to use the recommended way as stated by Symfony to pass dsn as parameter to the handler, and still make the websocketbundle work.

from websocketbundle.

jjsaunier avatar jjsaunier commented on June 3, 2024

Yes I did, but I do not see the relevance between this particular problem and cookies

Because your PHPSESSID can refer to a old session, before that you setup PDOSessionHandler and may create some weird bug.

Here my config who work under symfony 2.7.X

parameters:
    pdo.db_options:
        db_table:    sessions
        lock_mode: 0

services:
    pdo:
        class: PDO
        arguments:
            dsn: mysql:host=%database_host%;port=%database_port%;dbname=%database_name%
            user: %database_user%
            password: %database_password%
        calls:
            - [ setAttribute, [3, 2] ] # \PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION

    session.handler.pdo:
        class:     Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler
        arguments: [@pdo, %pdo.db_options%]

Which version of Symfony are you using ?
By removing public: false on session handler it work ?

from websocketbundle.

faheem00 avatar faheem00 commented on June 3, 2024

I am using Symfony 2.6.X

I removed public : false, and set the parameters as you defined above, but still the error shows. It seems to be related to passing the PDO class to the session handler.

Again providing my config for your kind information

    pdo:
        class: PDO
        arguments:
            dsn: mysql:host=%database_host%;port=%database_port%;dbname=%database_name%
            user: %database_user%
            password: %database_password%
        calls:
            - [ setAttribute, [3, 2] ] # \PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION

    session.handler.pdo:
        class:     Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler
        arguments: [@pdo, {db_table: sessions, lock_mode : 0}]

from websocketbundle.

jjsaunier avatar jjsaunier commented on June 3, 2024

and the websocket bundle configuration is something like :

gos_web_socket:
    client:
        firewall: secured_area
        session_handler: @session.handler.pdo

from websocketbundle.

shtumi avatar shtumi commented on June 3, 2024

Hello.
My config looks almost the same as here.
So i use session.handker.pdo.
But then when i run
$user = $this->clientManipulator->getClient($connection);
var_dump($user); die();
i expect see my currently authorized in user entity like if i receive it from token.
But i got
string(36) "anon-75600669455ddd1b87c298582826341"
So how can i get currently authorized user entity here?
Is it necessary to have redis client storage for this purpose?
Thank you

from websocketbundle.

shtumi avatar shtumi commented on June 3, 2024

Already found that it was incorrect domain in websocket host

from websocketbundle.

faheem00 avatar faheem00 commented on June 3, 2024

@Prophet777 my firewall's name is main, here is my websocket configuration

gos_web_socket:
    client:
            session_handler: @session.handler.pdo
            firewall: main # Example: secured_area, you must replace it by your firewall
    shared_config: true
    assetic: true #use assetic bundle
    server:
        host: "%websocket_host%"   #The host ip to bind to
        port: "%websocket_port%"        #The port the socket server will listen on
        router:
            resources:
                - @AppBundle/Resources/config/pubsub/routing.yml
    pushers:
            wamp:
                host: "%websocket_host%"
                port: "%websocket_port%"

The problem is unfortunately still showing. It's preventing me from starting on my projected plan, so it's really bothering me. Any kind of insight would be really helpful.

from websocketbundle.

faheem00 avatar faheem00 commented on June 3, 2024

Also, another thing - passing pdo as argument in session handler class is depreciated now in Symfony, so it would be best to come up with a solution where we can use websocket while passsing dsn only to the session handler.

from websocketbundle.

jjsaunier avatar jjsaunier commented on June 3, 2024

@faheem00 where did you see it's deprecated ???

https://github.com/symfony/symfony/blob/2.7/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php#L174

https://github.com/symfony/symfony/blob/2.8/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php#L174

from websocketbundle.

faheem00 avatar faheem00 commented on June 3, 2024

I think there was a miscommunication. By deprecated, I meant that passing pdo instance to the session handler is no longer recommended by the Symfony documentation, in their example they use the dsn string to pass to the session handler.

But yes, we can still use the pdo instance, but the problem here is what I am facing. I have set the settings as you exactly specified, but still I am shown the exception every time. Any way you can help?

from websocketbundle.

jjsaunier avatar jjsaunier commented on June 3, 2024

OK, you can still try by passing the dns as argument. My given example is not writen in marble :)
So if that work perfectly by passing dns, it's perfect. We just had to correct the docs.
I'm waiting your feedback if that work or not
Le 28 août 2015 07:54, Faheem Abrar [email protected] a écrit :I think there was a miscommunication. By deprecated, I meant that passing pdo instance to the session handler is no longer recommended by the Symfony documentation, in their example they use the dsn string to pass to the session handler.

But yes, we can still use the pdo instance, but the problem here is what I am facing. I have set the settings as you exactly specified, but still I am shown the exception every time. Any way you can help?

—Reply to this email directly or view it on GitHub.

from websocketbundle.

faheem00 avatar faheem00 commented on June 3, 2024

Passing dsn as argument was the first thing I tried. Here is the config:

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

Using this config, the server successfully starts, but when I browse a page on which I subscribed to a topic, the following error occurs:

PHP Fatal error:  Call to a member function prepare() on a non-object in /var/www/tour/vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php on line 511

on line 511 of the session handler is the following code:

$selectStmt = $this->pdo->prepare($selectSql);

My guess is that $this->pdo does not have a pdo instance for some reason. I am also using the same session handler as my current session handler, and it works without any problem, the problem is happening to the Ratchet server.

from websocketbundle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.