Skip to content

Cannot get server get the socket #24

@Freaders

Description

@Freaders

I know php emmiter is emiting the sockets, but server is not getting them.

This is my php code

$redis = new \Redis();
            $redis->connect('127.0.0.1', '6379');
            $emitter = new SocketIO\Emitter($redis);
            $emitter->broadcast->emit('haha', 'such data');

This is my server code

var io = require('socket.io')(3000);
var redis = require('socket.io-redis');
io.adapter(redis({ host: '127.0.0.1', port: 6379 }));
io.on('connection', function(socket){
    console.log(socket + " connected");
    socket.on('haha', function(data){
        console.log("data " + data);
    });
    socket.on('disconnect', function(){
        console.log(socket + " disconnected");
    });
});

redis-cli monitor output:

1466856693.275138 [0 127.0.0.1:34296] "info"
1466856693.276242 [0 127.0.0.1:34298] "info"
1466856693.284131 [0 127.0.0.1:34298] "subscribe" "socket.io#/#" //nodejs server start
1466856702.934495 [0 127.0.0.1:34332] "PUBLISH" "socket.io#/#" "\x93\xa7emitter\x83\xa4type\x02\xa4data\x92\xa4haha\xa9such data\xa3nsp\xa1/\x82\xa5rooms\x90\xa5flags\x81\xa9broadcast\xc3" //php code exec

Im running Ubuntu Server 16.04 with php7, node 4.4.6, redis-server 3.0.6. Any ideas why it doesnt work? Thanks a lot!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions