Skip to content

Share session not working #432

@krajcikondra

Description

@krajcikondra

Hi,

I am using symfony 5 with web server running by following command:
symfony server:start
and websocket server by command

php bin/console gos:websocket:server
Web server running on 127.0.0.1:8000
Websocket server running on 127.0.0.1:8888

I am using session store in database.

My configuration

gos_web_socket:
    server:
        port: 8888        # The port the socket server will listen on
        host: 127.0.0.1   # The host ip to bind to
        router:
            resources:
                - '%kernel.project_dir%/config/pubsub/routing.yaml'
    client:
        firewall: main # Can be an array of firewalls
        session_handler: 'session.handler.pdo'

services:
    app.websocket.topic.acme:
        class: App\Websocket\Topic\AcmeTopic
        tags:
            - { name: gos_web_socket.topic }

    session.handler.pdo:
        class: Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler
        arguments:
            - !service { class: PDO, factory: ['@database_connection', 'getWrappedConnection'] }
            - { lock_mode: 0 }

And when i dump sessionId in AcmeTopic::onPublish method

   public function onPublish(
        ConnectionInterface $connection,
        Topic $topic,
        WampRequest $request,
        $event,
        array $exclude,
        array $eligible
    ): void {

    	var_dump($event);
    	$this->logger->log('info', 'sessionId = ' . $connection->WAMP->sessionId);
    	var_dump('session', $connection->WAMP->sessionId);
    	...

framework.yaml

framework:
    secret: '%env(APP_SECRET)%'
    #csrf_protection: true
    #http_method_override: true

    # Enables session support. Note that the session will ONLY be started if you read or write from it.
    # Remove or comment this section to explicitly disable session support.
    session:
        handler_id: 'session.handler.pdo'
        name: 'PHPSESSID' # in php.ini is session name set to PHPSESSID too
        cookie_secure: auto
#        cookie_samesite: lax

then i get different sessionId (anonymouse) as expected.

Know somebody what I do wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions