Home > Software design >  Why do I see repeated https requests from the same socket.io client?
Why do I see repeated https requests from the same socket.io client?

Time:10-14

I was looking at my logs, and it seems on occasion, I have a great many socket.io get requests from the same user. Is this normal behavior or did I do something wrong?

12:24:29 method=GET path="/socket.io/?EIO=4&transport=polling&t=NnwU34x"  dyno=web.1 connect=0ms service=1ms status=200 bytes=233 protocol=https
12:24:30 method=GET path="/socket.io/?EIO=4&transport=polling&t=NnwU38N"  dyno=web.1 connect=0ms service=1ms status=200 bytes=233 protocol=https
12:24:37 method=GET path="/socket.io/?EIO=4&transport=polling&t=NnwU4Xd"  dyno=web.1 connect=0ms service=2ms status=200 bytes=233 protocol=https
12:24:45 method=GET path="/socket.io/?EIO=4&transport=polling&t=NnwU6oG"  dyno=web.1 connect=0ms service=1ms status=200 bytes=233 protocol=https
12:24:45 method=GET path="/socket.io/?EIO=4&transport=polling&t=NnwU6nE"  dyno=web.1 connect=0ms service=1ms status=200 bytes=233 protocol=https
12:24:51 method=GET path="/socket.io/?EIO=4&transport=polling&t=NnwU8QL"  dyno=web.1 connect=0ms service=1ms status=200 bytes=233 protocol=https
12:24:58 method=GET path="/socket.io/?EIO=4&transport=polling&t=NnwUA4O"  dyno=web.1 connect=0ms service=2ms status=200 bytes=233 protocol=https
12:25:04 method=GET path="/socket.io/?EIO=4&transport=polling&t=NnwUBXz"  dyno=web.1 connect=0ms service=1ms status=200 bytes=233 protocol=https
12:25:04 method=GET path="/socket.io/?EIO=4&transport=polling&t=NnwUBY-"  dyno=web.1 connect=0ms service=1ms status=200 bytes=233 protocol=https
12:25:04 method=GET path="/socket.io/?EIO=4&transport=polling&t=NnwUBZq"  dyno=web.1 connect=0ms service=7ms status=200 bytes=233 protocol=https
12:25:04 method=GET path="/socket.io/?EIO=4&transport=polling&t=NnwUBay"  dyno=web.1 connect=0ms service=1ms status=200 bytes=233 protocol=https
12:25:12 method=GET path="/socket.io/?EIO=4&transport=polling&t=NnwUDPB"  dyno=web.1 connect=0ms service=1ms status=200 bytes=233 protocol=https
12:25:12 method=GET path="/socket.io/?EIO=4&transport=polling&t=NnwUDNc"  dyno=web.1 connect=0ms service=1ms status=200 bytes=233 protocol=https
12:25:12 method=GET path="/socket.io/?EIO=4&transport=polling&t=NnwUDOU"  dyno=web.1 connect=0ms service=1ms status=200 bytes=233 protocol=https

Everything seems to be working, but occasionally my server seems to be hammered by these requests.

CodePudding user response:

on the client side, I replaced io.connect("url") with just io.connect() and it seemed to have solved the issue.

Thanks @jfriend00 - How many socket.io requests to server per user is too many? - for confirming my initialization appeared to be misconfigured.

CodePudding user response:

The transport=polling aspect of the URL:

/socket.io/?EIO=4&transport=polling&t=NnwU34x

appears to be a client that is trying to only use http polling, not the webSocket transport. That seems misconfigured and will cause repeated http(s) connections in a polling fashion to regularly check for new messages rather than making a persistent webSocket connection for the transport.

You should make sure that you aren't forcing the transport to polling in some way in the client and are allowing the webSocket transport to be used.

  • Related