1 year ago

How do I run Redis on Windows?

Posted 1 year ago by p0t4t0

I downloaded the files found here https://github.com/MicrosoftArchive/redis then followed this guide https://laracasts.com/discuss/channels/general-discussion/step-by-step-guide-to-installing-socketio-and-broadcasting-events-with-laravel-51 but it doesn't seem to be working.

My server.js file

const app = require('express')();
const http = require('http').Server(app);
const io = require('socket.io')(http);
const Redis = require('ioredis');
const redis = new Redis();

redis.subscribe('test-channel', function(err, count) {


redis.on('message', function(channel, message) {
  console.log('Message Received: ' + message);
  message = JSON.parse(message);
  io.emit(`${channel}:${message.event}`, message.data);

http.listen(3000, function() {
  console.log('Listening on Port 3000');

My web.php file

Route::get('/fire', function() {
  event(new App\Events\TestEvent());
  return "event fired";

Route::get('/', function () {
    return view('welcome');

My TestEvent.php file


namespace App\Events;

use Illuminate\Broadcasting\Channel;
use Illuminate\Queue\SerializesModels;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;

class TestEvent
    use Dispatchable, InteractsWithSockets, SerializesModels;

    public $data;

     * Create a new event instance.
     * @return void
    public function __construct()
        $this->data = array(
          'power' => '10'

     * Get the channels the event should broadcast on.
     * @return \Illuminate\Broadcasting\Channel|array
    public function broadcastOn()
        return ['test-channel'];
        // return new PrivateChannel('channel-name');

And lastly my test.blade.php file


  <div class="test">

  <script src="{{ asset('js/socket.io.js') }}" type="text/javascript"></script>
  <script type="text/javascript">
  var socket = io('');
  socket.on("test-channel:App\Events\TestEvent", function(message) {
    $('.test').text(parseInt($('.test').text()) + parseInt(message.data.power));

I have the redis-cli.exe and redis-server.exe files running but nothing seems to be happening, I tried checking if the redis-cli and redis-server commands work on my console but they don't. I can't really figure out how to fix this. Any help is appreciated. Thank you in advance.

Please sign in or create an account to participate in this conversation.