I've started to use Laravel 5.1 and its pretty awesome, just wanted to play around with the new 'Broadcasting Event' feature by using NodeJs as the server and Redis as the driver following the guide here: http://blog.nedex.io/laravel-5-1-broadcasting-events-using-redis-driver-socket-io/. When i fire an event which implements the ShouldBroadcast interface i receive an error: "Error while reading line from the server. [tcp://127.0.0.1:4365]"
4365 - is the port which the server is running on (listening in that port). Do you have any idea why does it happend?
I tried also to use Redis directly:
$redis = Redis::connection();
$redis->publish('test-channel', 'msg');
Got the same result, "Error while reading line from the server. [tcp://127.0.0.1:4365]".
socket.js:
var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);
var Redis = require('ioredis');
var redis = new Redis();
redis.subscribe('test-channel', function(err, count) {
});
redis.on('message', function(channel, message) {
console.log('Message Recieved: ' + message);
message = JSON.parse(message);
io.emit(channel + ':' + message.event, message.payload);
});
http.listen(4365, function(){
console.log('Listening on Port 4365');
});
config\database.php:
'redis' => [
'cluster' => false,
'default' => [
'host' => '127.0.0.1',
'port' => 4365,
'database' => 0,
'timeout' => 100,
],
],
Tried to change the defulat timeout, set it to 0, -1 or >10 Also tried to disable Xdebug in php.ini the problem persists.
I made some debug deeply to the code trying to undertand what might cause this problem and it fails in class: Predis\Connection\StreamConnection
public function read()
{
$socket = $this->getResource();
$chunk = fgets($socket);
if ($chunk === false || $chunk === '') {
$this->onConnectionError('Error while reading line from the server.');
}
...
chunk is false why? And why does the redis client is trying to read data from the server, for my understanding it should 'publish' data to the server, means it should write (broadcast) not read..