ws: Connect to websocket under cloudflare causes 403 forbidden error

  • I’ve searched for any related issues and avoided creating a duplicate issue.

Description

I am trying to connect to websocket under cloudflare, and it refuse connection with 403 forbidden error.

When I am trying this in node.js, connection refused with 403 code.

new WebSocket('wss://live-arena-rjsqbe.agar.io/?party_id=GPUBAM', [], {
            headers: {
                Accept: `*/*`,
                "Accept-Encoding": `gzip, deflate, br`,
                "Accept-Language": `en-GB,en;q=0.5`,
                "Cache-Control": `no-cache`,
                Connection: `keep-alive, Upgrade`,
                ... More headers here ...
            },
        })
        "websocket": "^1.0.34",
        "ws": "^7.1.2",
        "wss": "^3.3.4"

When I am trying to connect to websocket in this way from browser, it works fine.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 19 (8 by maintainers)

Most upvoted comments

You can try to shuffle the default ciphers. See https://httptoolkit.tech/blog/tls-fingerprinting-node-js/.