title: Ratchetphp websocket error in server related with load balancer
body: <p>I have issue with websocket when using load balancer . We have 3 three different servers which using same php packages. When user connects to websocket proxy redirect user to any working (example. A server, A1 user) server. Then php server creates new Resource contained user resource id , remote address and some informations. When other users connects then proxy redirect user another server (example. B server B1 user )and this process repeat again. But this time resource belongs to antother server (example. B server). Problem is there.. When we need emit message from A1 user to B1 , server can't find B1 user, because his resource located in A server.</p>
  <p><strong>How to can i connect this user whith one another ??</strong></p>
  <p>Code is such:</p>
  <pre><code>&lt;?php
  
  namespace App\Lib\Notify;
  
  use App\Lib\Notify\Messages\SocketMessagesFactory;
  use App\Models\Mongo\CacheRequest;
  use App\Models\TwoFactorAuth;
  use Illuminate\Support\Facades\Redis;
  use Ratchet\MessageComponentInterface;
  use Ratchet\ConnectionInterface;
  use React\EventLoop\Loop;
  use React\EventLoop\LoopInterface;
  
  class SocketServer implements MessageComponentInterface
  {
      use SocketAuth, SocketBind,SocketCLIMessages;
  
      protected $redis;
      public static $clients;
      public static $localClients;
  
  
      public function __construct()
      {
          $this-&gt;redis = Redis::connection();
  
          /* Deleting all users from redis related old session */
          self::getKeysLoop('users:*', function ($user, $index) {
              $this-&gt;redis-&gt;del($index);
          });
  
          /* Deleting all confirmation reqeusts */
          self::getKeysLoop('confirm:*', function ($user, $index) {
              $this-&gt;redis-&gt;del($index);
          });
  
          TwoFactorAuth::truncate();
          CacheRequest::truncate();
  
          echo self::datetime().&quot;\033[34mDeleted all cached users from online (redis) \033[0m \n&quot;;
      }
  
      /*
       * When connection opened
       * */
      public function onOpen(ConnectionInterface $conn)
      {
          $query = $conn-&gt;httpRequest-&gt;getUri()-&gt;getQuery();
          parse_str($query, $queryArr);
          echo self::datetime(). &quot;Connecting ip: &quot;.$conn-&gt;remoteAddress.&quot; ... \n&quot;;
               
          $auth = self::checkToken(($queryArr['token']) ?? null);
  
              if ($auth['success']) {
                  $user = $this-&gt;redis-&gt;hgetall('users:' . $auth['user']-&gt;data-&gt;userId);
  
                  /* Append to online */
                  if ($user) {
                      #$this-&gt;usersCount[$auth['user']-&gt;data-&gt;userId]++;
                      echo self::datetime().'Push resource to exist user : (userID: '.$auth['user']-&gt;data-&gt;userId.' )' . &quot;\n&quot;;
                      self::pushToArr('users:' . $auth['user']-&gt;data-&gt;userId, $user, 'resources', $conn-&gt;resourceId);
                  } else {
  
                      echo self::datetime().'Connected user (id: '.$auth['user']-&gt;data-&gt;userId.') ' . &quot;\n&quot;;
                      $conn-&gt;send('Welcome from Wesocket ! Successfully connection.');
                      /* Binding to session  */
                      self::bindUser($conn,$queryArr['token'],$auth);
                  }
  
                  /* Bind to general line */
                  self::$clients[$conn-&gt;resourceId] = $conn;
              }else{
  
                  /* Close when bad authorized */
                  $conn-&gt;close();
                  echo self::datetime().&quot;Error in auth: &quot; . $auth['message'] . &quot;\n&quot;;
              }
          
      }
  
      /*
      * When message from users
      * */
      public function onMessage(ConnectionInterface $conn, $msg)
      {
          if(is_string($msg)) {
              $message = json_decode($msg);
              if(json_last_error()===JSON_ERROR_NONE) {
                  if(isset($message-&gt;type) &amp;&amp; is_string($message-&gt;type) &amp;&amp; method_exists(SocketMessagesFactory::class,$message-&gt;type)) {
                      $method = $message-&gt;type;
                      SocketMessagesFactory::$method($message,$conn);
                  }
              }
          }
      }
  
  
      public function onClose(ConnectionInterface $conn)
      {
          self::controllableLogout($conn);
          unset(self::$clients[$conn-&gt;resourceId]);
          unset(self::$localClients[$conn-&gt;resourceId]);
          echo self::datetime().&quot;Connection closed for ({$conn-&gt;remoteAddress}) &quot; . $conn-&gt;resourceId . &quot;\n&quot;;
          #print_r( self::findUserByResource($conn-&gt;resourceId));
      }
  
  
      public function onError(ConnectionInterface $conn, \Exception $e)
      {
          echo self::datetime().&quot;Error message: &quot; . (string)$e-&gt;getMessage() . &quot;\n&quot;;
          $conn-&gt;close();
      }
  
  </code></pre>