<p>I am trying to migrate a socket io service from GCP (App Engine) to a kubernetes cluster.
Everything works fine on the GCP side (we have one instance of the server without replicas).
The migration to k8s is going very well, except that when connecting the client socket to the server, it does not receive some information:</p>
<ul>
<li><p>In transport 'polling': Of course, as there are two pods, this doesn't work properly anymore and the client socket keeps deconnecting / reconnecting in loop.</p>
</li>
<li><p>In 'websocket' transport: The connection is correctly established, the client can receive data from the server in 'broadcast to all client' mode =&gt; <code>socket.emit('getDeviceList', os.hostname())</code> but, as soon as the server tries to send data only to the concerned client <code>io.of(namespace).to(socket.id).emit('getDeviceList', JSON.stringify(obj))</code>, this one doesn't receive anything...</p>
</li>
<li><p>Moreover, I modified my service to have only one pod for a test, the polling mode works correctly, but, I find myself in the same case as the websocket mode =&gt; I can't send an information to a precise client...</p>
</li>
</ul>
<p>Of course, the same code on the App Engine side works correctly and the client receives everything correctly.</p>
<p>I'm working with:</p>
<pre><code>&quot;socket.io&quot;: &quot;^3.1.0&quot;,
&quot;socket.io-redis&quot;: &quot;^5.2.0&quot;,
&quot;vue&quot;: &quot;^2.5.18&quot;,
&quot;vue-socket.io&quot;: &quot;3.0.7&quot;,
</code></pre>
<p>My server side configuration:</p>
<pre><code>var io = require('socket.io')(server, {
  pingTimeout: 5000,
  pingInterval : 2000,
  cors: {
      origin: true, 
      methods: [&quot;GET&quot;, &quot;POST&quot;],
      transports: ['websocket', 'polling'],
      credentials: true
  },
  allowEIO3: true
});
io.adapter(redis({ host: redis_host, port: redis_port }))
</code></pre>
<p>My front side configuration:</p>
<pre><code>Vue.use(new VueSocketIO({
    debug: true,
    connection: 'path_to_the_socket_io/namespace,
    options: {
        query: `id=..._timestamp`,
        transports: ['polling']
    }
}));
</code></pre>
<p>My ingress side annotation:</p>
<pre><code>kubernetes.io/ingress.class: nginx                               kubernetes.io/ingress.global-static-ip-name: ip-loadbalancer                                   
meta.helm.sh/release-name: xxx                                             
meta.helm.sh/release-namespace: xxx -release                                       nginx.ingress.kubernetes.io/affinity: cookie                     nginx.ingress.kubernetes.io/affinity-mode: persistent                   nginx.ingress.kubernetes.io/force-ssl-redirect: true                                                              nginx.ingress.kubernetes.io/proxy-connect-timeout: 10800  
nginx.ingress.kubernetes.io/proxy-read-timeout: 10800
nginx.ingress.kubernetes.io/proxy-send-timeout: 10800
nginx.org/websocket-services: app-sockets-cluster-ip-service 
</code></pre>
<p>My question is : why i can get broadcast to all user message and not specific message to my  socket ?</p>
<p>Can someone try to help me ?  :)</p>
<p>Thanks a lot !</p>

<p>I found the solution in the day.and share it.</p>
<p>In fact, the problem is not due to the kubernetes Cluster but due to the socket io and socket io redis adapter version.</p>
<p>I was using <code>socket.io: 3.x.x</code> and using <code>socket.io-redis: 5.x.x</code>
In fact, i need to use the <code>socket.io-redis: 6.x.x</code> with this version of socket io :)</p>
<p>You can find the compatible version of socket io and redis adapter here:
<a href="https://github.com/socketio/socket.io-redis-adapter#compatibility-table" rel="nofollow noreferrer">https://github.com/socketio/socket.io-redis-adapter#compatibility-table</a></p>
<p>Thanks a lot.</p>
