title: Socket.IO duplicated message
body: <p>I'm trying to build a chat application using Laravel, with node js server, socketio and redis. What I have is this:</p>
  
  <p><strong>Client JS:</strong></p>
  
  <pre><code>var socket = io('http://localhost:3005');
   var room = '17';
    $("#send").click(function(){
      content = $("textarea").val();
      id =$("#id").val();
      $.ajax({
        url: "{{route('send.message')}}",
        method: "POST",
        data: {content, id, room},
        success: function(){
        }
      });
    });
  
    socket.on('cacad', function(message){
            console.log(message); //multiple copies here
        });
  
    socket.on('connect', function(){
      console.log("Connected!");
      socket.emit('room', room);
    });
  </code></pre>
  
  <p><strong>Laravel Controller:</strong></p>
  
  <pre><code>public function sendMessage(Request $request){
   event(new EventName($request-&gt;all()));
    $message = new Message;
    $message-&gt;message = $request-&gt;content;
    $redis = LRedis::connection();
    $redis-&gt;publish('chat-channel', json_encode($request-&gt;all()));
    $message-&gt;save();
  }
  </code></pre>
  
  <p><strong>Node Server:</strong></p>
  
  <pre><code>var app = require('express')();
  var http = require('http').Server(app);
  var io = require('socket.io')(http);
  var redis = require('ioredis');
  
  var myMessage;
  var redis_client = redis.createClient();
  
  redis_client.subscribe('chat-channel');
  
  io.on('connection', function(socket) {
  
      redis_client.on('message', function(channel, message) {
        var myData = JSON.parse(message);
          socket.broadcast.to('17').emit('cacad', 'u i u a a');
      });
  
  
      socket.on('room', function(room){
          socket.join(room);
      });
  
      socket.on('disconnect', function(){
        console.log("disconnected!");
      });
  });
  
  
  http.listen(3005, function() {
      console.log('Listening on Port 3005');
  });
  </code></pre>
  
  <p>I am trying to broadcast a message <code>u i u a a</code> in room 17. But when I receive it in the console, it shows multiple copies of it, 2x-4x. In the Laravel controller I publish a message using redis and I subscribe to it in node server. It is received successfully, but the problem lies with the multiple copies of the message (client side). </p>
  
  <p>Please where is it wrong? Thank you :)</p>