These are chat archives for oncesk/yii-node-socket

4th
Nov 2015
Huy Nguyen Quang
@hnq90
Nov 04 2015 03:16
@oncesk I'm using your package from master branch
But elephant.io seem still old version
oncesk
@oncesk
Nov 04 2015 07:02
hm, and what?
Huy Nguyen Quang
@hnq90
Nov 04 2015 07:03
I couldn't send event from yii controller
I'm using Ubuntu 14.04 (curl is already installed)
oncesk
@oncesk
Nov 04 2015 07:03
why? can you give me more detailed explanation
Huy Nguyen Quang
@hnq90
Nov 04 2015 07:03
No exception is thrown
Example:
public function actionIndex()
    {
        $frame = Yii::$app->nodeSocket->getFrameFactory()->createAuthenticationFrame();
        $frame->setUserId(1);
        $frame->send();
        return $this->render('index');
    }
This is my action Index
oncesk
@oncesk
Nov 04 2015 07:05
ok
Huy Nguyen Quang
@hnq90
Nov 04 2015 07:05
This is action about:
public function actionAbout()
    {
       $event = Yii::$app->nodeSocket->getFrameFactory()->createUserEventFrame();
        $event->setUserId(1);
        $event->setEventName('message');
        $event['text'] = 'Hello, how are you?';
        $event->send();

        return $this->render('about');
    }
oncesk
@oncesk
Nov 04 2015 07:05
did you started session?
can you show me nodejs logs
?
Huy Nguyen Quang
@hnq90
Nov 04 2015 07:05
Please wait
oncesk
@oncesk
Nov 04 2015 07:05
ok
i am waiting
Huy Nguyen Quang
@hnq90
Nov 04 2015 07:12
tail -f /var/log/node-socket.log
debug: served static content /socket.io.js
debug: client authorized
info: handshake authorized iE42JJnMGjS3R1ASVZ5v
debug: setting request GET /socket.io/1/websocket/iE42JJnMGjS3R1ASVZ5v
debug: set heartbeat interval for client iE42JJnMGjS3R1ASVZ5v
debug: client authorized for 
debug: websocket writing 1::
debug: client authorized for /client
debug: websocket writing 1::/client
Tying connect socket to room
Room test
Socket connected
debug: sending data ack packet
debug: websocket writing 6::/client:1+[true,1]
debug: client authorized
info: handshake authorized Kd2zIGl9o_5_iT3QVZ5w
debug: setting request GET /socket.io/1/websocket/Kd2zIGl9o_5_iT3QVZ5w
debug: set heartbeat interval for client Kd2zIGl9o_5_iT3QVZ5w
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 Kd2zIGl9o_5_iT3QVZ5w
debug: cleared close timeout for client Kd2zIGl9o_5_iT3QVZ5w
debug: cleared heartbeat interval for client Kd2zIGl9o_5_iT3QVZ5w
debug: discarding transport
info: transport end (undefined)
debug: set close timeout for client B4j2DRLV-6xUKBVZVZ5r
debug: cleared close timeout for client B4j2DRLV-6xUKBVZVZ5r
debug: cleared heartbeat interval for client B4j2DRLV-6xUKBVZVZ5r
debug: discarding transport
debug: served static content /socket.io.js
debug: client authorized
info: handshake authorized elKVfbkfUH1aezoXVZ5x
debug: setting request GET /socket.io/1/websocket/elKVfbkfUH1aezoXVZ5x
debug: set heartbeat interval for client elKVfbkfUH1aezoXVZ5x
debug: client authorized for 
debug: websocket writing 1::
debug: client authorized for /client
debug: websocket writing 1::/client
@oncesk Please check it.
oncesk
@oncesk
Nov 04 2015 07:12
warn: handshake error PHPSESSID is undefined for /server
Huy Nguyen Quang
@hnq90
Nov 04 2015 07:13
I go to /index page and go to /about page but no log
Huy Nguyen Quang
@hnq90
Nov 04 2015 07:13
Oh, please wait.
oncesk
@oncesk
Nov 04 2015 07:14
oncesk/yii-node-socket#57
Huy Nguyen Quang
@hnq90
Nov 04 2015 07:14
I updated the log
I can emit the message between client side
oncesk
@oncesk
Nov 04 2015 07:14
ok
Huy Nguyen Quang
@hnq90
Nov 04 2015 07:15
But I couldn't emit message from php to socket.io server
oncesk
@oncesk
Nov 04 2015 07:16
you trying to emit authentication message, this message should authenticate user on nodejs server
did you tried send simple event frame?
only start session before
because now nodejs reject your connections because session is not sending
Huy Nguyen Quang
@hnq90
Nov 04 2015 07:22
Oh, so I have to open session before emit message?
oncesk
@oncesk
Nov 04 2015 07:22
yes
Huy Nguyen Quang
@hnq90
Nov 04 2015 07:22
Do you have any solution than open Yii session?
 $session = Yii::$app->session;
        $session->open();
        $frame = Yii::$app->nodeSocket->getFrameFactory()->createEventFrame();
        $frame->setEventName('updateBoard');
        $frame['boardId'] = 25;
        $frame['boardData'] = 'Test';
        $frame->send();
        return $this->render('index');
I have to do like that
oncesk
@oncesk
Nov 04 2015 07:23
ok, now open that action and show nodejs logs
session needed for client authorization
for emit messages to concrete user
Huy Nguyen Quang
@hnq90
Nov 04 2015 07:24
tail: /var/log/node-socket.log: file truncated
info: socket.io started
Listening frontend.dev:3001
Set origin:  *:*
debug: client authorized
info: handshake authorized tBgrGjMN8aMamNCxYdSX
debug: setting request GET /socket.io/1/websocket/tBgrGjMN8aMamNCxYdSX
debug: set heartbeat interval for client tBgrGjMN8aMamNCxYdSX
debug: client authorized for 
debug: websocket writing 1::
debug: client authorized for /client
debug: websocket writing 1::/client
debug: client authorized
info: handshake authorized m0V0r5W3hlnk10zPYdSY
debug: setting request GET /socket.io/1/websocket/m0V0r5W3hlnk10zPYdSY
debug: set heartbeat interval for client m0V0r5W3hlnk10zPYdSY
debug: client authorized for 
debug: websocket writing 1::
debug: client authorized for /client
debug: websocket writing 1::/client
debug: client authorized
info: handshake authorized K6vDXrgvQ6v1uh3CYdSZ
debug: setting request GET /socket.io/1/websocket/K6vDXrgvQ6v1uh3CYdSZ
debug: set heartbeat interval for client K6vDXrgvQ6v1uh3CYdSZ
debug: client authorized for 
debug: websocket writing 1::
debug: client authorized for /server
debug: websocket writing 1::/server
debug: websocket writing 5::/client:{"name":"global:updateBoard","args":[{"boardId":25,"boardData":"Test"}]}
debug: websocket writing 5::/client:{"name":"global:updateBoard","args":[{"boardId":25,"boardData":"Test"}]}
info: transport end (undefined)
debug: set close timeout for client K6vDXrgvQ6v1uh3CYdSZ
debug: cleared close timeout for client K6vDXrgvQ6v1uh3CYdSZ
debug: cleared heartbeat interval for client K6vDXrgvQ6v1uh3CYdSZ
debug: discarding transport
info: transport end (undefined)
debug: set close timeout for client m0V0r5W3hlnk10zPYdSY
debug: cleared close timeout for client m0V0r5W3hlnk10zPYdSY
debug: cleared heartbeat interval for client m0V0r5W3hlnk10zPYdSY
debug: discarding transport
debug: served static content /socket.io.js
debug: client authorized
info: handshake authorized uy4TUwlM0YedejfmYdSa
debug: setting request GET /socket.io/1/websocket/uy4TUwlM0YedejfmYdSa
debug: set heartbeat interval for client uy4TUwlM0YedejfmYdSa
debug: client authorized for 
debug: websocket writing 1::
debug: client authorized for /client
debug: websocket writing 1::/client
Tying connect socket to room
Room test
Socket connected
debug: sending data ack packet
debug: websocket writing 6::/client:1+[true,1]
That's my new log
oncesk
@oncesk
Nov 04 2015 07:25
so, seems like all works fine, now subscribe to updateBoard event in js and you listener will be fired
Huy Nguyen Quang
@hnq90
Nov 04 2015 07:25
Yeah, thank you so much.
oncesk
@oncesk
Nov 04 2015 07:26
do not at all=)
Huy Nguyen Quang
@hnq90
Nov 04 2015 07:26
Could I call session open in Yii callback?
like beforeAction
oncesk
@oncesk
Nov 04 2015 07:27
you can, but i do not know how do it more efficient in your application
Huy Nguyen Quang
@hnq90
Nov 04 2015 07:27
Okay, thank you for your support.
Elephant.io has version 3.0
But it isn't compatible with your library
oncesk
@oncesk
Nov 04 2015 07:30
yes, it is, if you want you can create pull request with new elephant.io version
Huy Nguyen Quang
@hnq90
Nov 04 2015 07:32
Yeah, may be in next few days :D
oncesk
@oncesk
Nov 04 2015 07:33
ok, and you can implement support for https
i can send to you working code)
Huy Nguyen Quang
@hnq90
Nov 04 2015 07:38
Yes
Please send it to me
oncesk
@oncesk
Nov 04 2015 07:39
on which email