socket.io icon indicating copy to clipboard operation
socket.io copied to clipboard

Session ID unknown

Open MuhammedAlmaz opened this issue 3 years ago • 0 comments

Hello i made a project with node.js socket.io and proxy with apache2. Everything is ok project working fine but sometimes my all connection sending a connection error which message is "Session ID unknown". I tried everything i changed my server from apache2 to nginx but it doesn't work also. The connections are sending that error message like every 1 h. How can i solve the issue i don't know. I'm working like 8 days about it. My projects working a lot slowly. Can someone help please? I had like 100-150 socket connection but when i get this error i'm getting like 100-150k error message and log file filling a lot.

Versions Apache2: Apache/2.4.54 (Ubuntu) Socket.io Server: 4.5.1 Socket.io Client: 4.5.1

Error line

    IO.instance.engine.on('connection_error', (err) => {
      console.log('connection_error', err.message); // <---- this line
    });

Apache2 conf file

<VirtualHost _default_:443>
        ServerName socket.myproject.com
        SSLEngine On
        SSLCertificateFile /etc/ssl/socket/primary.crt
        SSLCertificateKeyFile /etc/ssl/socket/private.key
        SSLCertificateChainFile /etc/ssl/socket/intermediate.crt
LoadModule authn_file_module            modules/mod_authn_file.so
LoadModule authn_core_module            modules/mod_authn_core.so
LoadModule authz_host_module            modules/mod_authz_host.so
LoadModule authz_groupfile_module       modules/mod_authz_groupfile.so
LoadModule authz_user_module            modules/mod_authz_user.so
LoadModule authz_core_module            modules/mod_authz_core.so
LoadModule headers_module               modules/mod_headers.so
LoadModule lbmethod_byrequests_module   modules/mod_lbmethod_byrequests.so
LoadModule proxy_module                 modules/mod_proxy.so
LoadModule proxy_balancer_module        modules/mod_proxy_balancer.so
LoadModule proxy_http_module            modules/mod_proxy_http.so
LoadModule proxy_wstunnel_module        modules/mod_proxy_wstunnel.so
LoadModule rewrite_module               modules/mod_rewrite.so
LoadModule slotmem_shm_module           modules/mod_slotmem_shm.so
# User daemon
# Group daemon
Header add Set-Cookie "SERVERID=sticky.%{BALANCER_WORKER_ROUTE}e; path=/" env=BALANCER_ROUTE_CHANGED
<Proxy "balancer://nodes_polling">
    BalancerMember "http://localhost:1002"    route=prod
    ProxySet stickysession=SERVERID
</Proxy>
<Proxy "balancer://nodes_ws">
    BalancerMember "ws://localhost:1002"    route=prod
    ProxySet stickysession=SERVERID
</Proxy>
RewriteEngine On
RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteRule /(.*) balancer://nodes_ws/$1 [P,L]
RewriteCond %{HTTP:Upgrade} !=websocket [NC]
RewriteRule /(.*) balancer://nodes_polling/$1 [P,L]
ProxyTimeout 3
    </VirtualHost>

Client

this.IO = io(AppConstants.socketBaseUrl, {
  query: { token:"blablabla...." },
  path: '/socket.io',
  withCredentials: true,
  transports: ['websocket', 'polling'],
  secure: true,
});

Server side code

const socketServer = require('socket.io')(Server, {
  transports: ['websocket', 'polling'],
  cors: {
    origin: '*',
    credentials: true,
    methods: ['GET', 'POST'],
  },
});

MuhammedAlmaz avatar Jul 26 '22 17:07 MuhammedAlmaz