question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Keep getting and posting /socket.io/?EIO=3&transport=polling&t=

See original GitHub issue

My backend in ExpressJS and NodeJS used to work well. I just realized that logs exploded the disk (the backend is still functional), because when the backend is on, it keeps trying:

kpi.js GET /socket.io/?EIO=3&transport=polling&t=NBiaEK6
index.js GET /socket.io/?EIO=3&transport=polling&t=NBiaEK6
index.js router.get *
kpi.js POST /socket.io/?EIO=3&transport=polling&t=NBiaER6
index.js POST /socket.io/?EIO=3&transport=polling&t=NBiaER6
Error: Not Found
    at /opt/funfun/app.js:99:13
    at Layer.handle [as handle_request] (/opt/funfun/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/opt/funfun/node_modules/express/lib/router/index.js:317:13)
    at /opt/funfun/node_modules/express/lib/router/index.js:284:7
    at Function.process_params (/opt/funfun/node_modules/express/lib/router/index.js:335:12)
    at next (/opt/funfun/node_modules/express/lib/router/index.js:275:10)
    at /opt/funfun/node_modules/express/lib/router/index.js:635:15
    at next (/opt/funfun/node_modules/express/lib/router/index.js:260:14)
    at /opt/funfun/routes/index.js:18:2
    at Layer.handle [as handle_request] (/opt/funfun/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/opt/funfun/node_modules/express/lib/router/index.js:317:13)
    at /opt/funfun/node_modules/express/lib/router/index.js:284:7
    at Function.process_params (/opt/funfun/node_modules/express/lib/router/index.js:335:12)
    at next (/opt/funfun/node_modules/express/lib/router/index.js:275:10)
    at Function.handle (/opt/funfun/node_modules/express/lib/router/index.js:174:3)
    at router (/opt/funfun/node_modules/express/lib/router/index.js:47:12)
    at Layer.handle [as handle_request] (/opt/funfun/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/opt/funfun/node_modules/express/lib/router/index.js:317:13)
    at /opt/funfun/node_modules/express/lib/router/index.js:284:7
    at Function.process_params (/opt/funfun/node_modules/express/lib/router/index.js:335:12)
    at next (/opt/funfun/node_modules/express/lib/router/index.js:275:10)
    at /opt/funfun/node_modules/express/lib/router/index.js:635:15
kpi.js GET /socket.io/?EIO=3&transport=polling&t=NBiaF8A
index.js GET /socket.io/?EIO=3&transport=polling&t=NBiaF8A
index.js router.get *
kpi.js POST /socket.io/?EIO=3&transport=polling&t=NBiaFFz
index.js POST /socket.io/?EIO=3&transport=polling&t=NBiaFFz
Error: Not Found
    at /opt/funfun/app.js:99:13
    at Layer.handle [as handle_request] (/opt/funfun/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/opt/funfun/node_modules/express/lib/router/index.js:317:13)
    at /opt/funfun/node_modules/express/lib/router/index.js:284:7
    at Function.process_params (/opt/funfun/node_modules/express/lib/router/index.js:335:12)
    at next (/opt/funfun/node_modules/express/lib/router/index.js:275:10)
    at /opt/funfun/node_modules/express/lib/router/index.js:635:15
    at next (/opt/funfun/node_modules/express/lib/router/index.js:260:14)
    at /opt/funfun/routes/index.js:18:2
    at Layer.handle [as handle_request] (/opt/funfun/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/opt/funfun/node_modules/express/lib/router/index.js:317:13)
    at /opt/funfun/node_modules/express/lib/router/index.js:284:7
    at Function.process_params (/opt/funfun/node_modules/express/lib/router/index.js:335:12)
    at next (/opt/funfun/node_modules/express/lib/router/index.js:275:10)
    at Function.handle (/opt/funfun/node_modules/express/lib/router/index.js:174:3)
    at router (/opt/funfun/node_modules/express/lib/router/index.js:47:12)
    at Layer.handle [as handle_request] (/opt/funfun/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/opt/funfun/node_modules/express/lib/router/index.js:317:13)
    at /opt/funfun/node_modules/express/lib/router/index.js:284:7
    at Function.process_params (/opt/funfun/node_modules/express/lib/router/index.js:335:12)
    at next (/opt/funfun/node_modules/express/lib/router/index.js:275:10)
    at /opt/funfun/node_modules/express/lib/router/index.js:635:15

kpi.js GET ... and index.js GET ... are what I print. Here is the code of opt/funfun/app.js:

// catch 404 and forward to error handler
app.use(function (req, res, next) {
  var err = new Error('Not Found');  // line 99
  err.status = 404;
  next(err);
});

Does anyone know what may be the reason?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
darrachequesnecommented, Dec 21, 2021

@AvalancheAccessories this is the configuration for NginX, used as a reverse proxy in front of your Socket.IO server(s)

Reference: https://socket.io/docs/v4/reverse-proxy/#nginx

Regarding the initial issue, the multiple requests might be due to a v2 client which tries to connect.

For v3 and above, you need to enable backward compatible mode on the server side:

import { Server } from "socket.io";

const io = new Server({
  allowEIO3: true
});

Reference: https://socket.io/docs/v4/server-options/#alloweio3

You can check those specific errors by listening to the connection_error event:

io.engine.on("connection_error", (err) => {
  if (err.code === 5) {
    // Unsupported protocol version
  }
});

Reference: https://socket.io/docs/v4/server-api/#event-connection_error

1reaction
vencommented, Jul 26, 2020

Hi,

Try this:

server {
    listen 80;
    server_name YOURDOMAIN.COM;
    client_max_body_size 100M;
    location /socket.io/ {
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_set_header Host $host;
        proxy_pass http://localhost:PORTNUMBER/socket.io/;
    }
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

How it works | Socket.IO
The HTTP long-polling transport (also simply referred as "polling") consists of successive HTTP requests: long-running GET requests, ...
Read more >
Socket.io cannot connect, resorts to "polling" - Stack Overflow
1. The socket.io protocol starts with a request to negotiate what type of connection to use. · What version of socket.io are you...
Read more >
Multiple connections being made/dropped using polling ...
Hi there, For starters, I am using Socket.io 2.1.1 (old, I know but it worked ... It appears though that the polling version...
Read more >
Everything you need to know about Socket.IO - Ably Realtime
Another issue with scaling Socket.IO is that whilst WebSockets hold their connection open, if the connection falls back to polling then there ...
Read more >
[Socket.IO] Polling vs. WebSocket Transport – on Balancing ...
In this case if you are using Least or Round Robin balancer it becomes problem as Socket.IO has to handshake with Server (or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found