oncesk / yii-node-socket

66 stars 46 forks source link

handshake error PHPSESSID #57

Closed ToRvaLDz closed 9 years ago

ToRvaLDz commented 9 years ago

Hello, thank you for your work!

Anyway I got an error when I try the example, like :

$event = Yii::$app->nodeSocket->getFrameFactory()->createEventFrame();
        $event->setEventName('event.example');
        $event['data'] = array(
            1,
            array(
                'red',
                'black',
                'white'
            )
        );
        $event->send();

I got:

debug: client authorized
info: handshake authorized 6kKMCtN5oVddD8pirJYT
debug: setting request GET /socket.io/1/websocket/6kKMCtN5oVddD8pirJYT
debug: set heartbeat interval for client 6kKMCtN5oVddD8pirJYT
debug: client authorized for 
debug: websocket writing 1::
debug: client unauthorized for /server
warn: handshake error PHPSESSID is undefined for /server
debug: websocket writing 7::/server:undefined
info: transport end (undefined)
debug: set close timeout for client 6kKMCtN5oVddD8pirJYT
debug: cleared close timeout for client 6kKMCtN5oVddD8pirJYT
debug: cleared heartbeat interval for client 6kKMCtN5oVddD8pirJYT
debug: discarding transport

I tried to debug server.js and it seems that the variable data.cookie.PHPSESSID is empty, I also checked the header and it have the PHPSESSID.

I have no problem on js side.

Can you help me please?

Rjgoolsby commented 9 years ago

Yii2 doesn't start session automatically. You have to add

$session = new Session;
$session->open();

See my comment here https://github.com/oncesk/yii-node-socket/issues/56#issuecomment-133086245

ToRvaLDz commented 9 years ago

Thank you it solve the problem!