Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot get server get the socket #24

Open
Freaders opened this issue Jun 25, 2016 · 2 comments
Open

Cannot get server get the socket #24

Freaders opened this issue Jun 25, 2016 · 2 comments

Comments

@Freaders
Copy link

Freaders commented Jun 25, 2016

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!

@aPoCoMiLogin
Copy link

This is related to broken compatibility between socket.io-redis and socket.io-php-emitter, and there is PR for that, for few months already: https://github.com/rase-/socket.io-php-emitter/pull/21 but @rase- seems to not bothering about state of his repo. Instead I'd suggest you to use @ashiina package: https://packagist.org/packages/ashiina/socket.io-emitter which is basically his PR merged.

@Freaders
Copy link
Author

Freaders commented Jun 25, 2016

@aPoCoMiLogin Im using his package and it is not working, should i use older version of socket.io-redis? What version should i use? Thanks
composer info:

ashiina/socket.io-emitter 0.8.0 *Maintained* A PHP implementation of socket...
ptrofimov/tinyredisclient 1.1.1 The most lightweight Redis client written i...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants