Is there a limit on the number of websockets?

1. Output of caddy version:

v2.5.1 h1:bAWwslD1jNeCzDa+jDCNwb8M3UJ2tPa8UZFFzPVmGKs=

Question:

Does Caddy limit the maximum number of websockets?

I’m new to using caddy, and I don’t really manage it myself. I deploy with hatchbox.io and their new site uses caddy. The old site uses Nginx.

Under Nginx, there was a fairly low limit for the maximum number of websockets. I have had to tweak that in the configuration.

I have done some searching in the caddy documentation, and haven’t come across any similar limit or configuration (there is almost no mention of websockets at all).

I wanted to check that I wasn’t missing something.

Is there a limit - or can I just let Caddy do its magic without worrying?

thank you

Not really, no. Just make sure your system is configured properly if you are going to have millions of connections concurrently or something :slight_smile:

Thanks Matt - that’s very reassuring.

No expectation of millions, but potentially thousands.
iirc - the default Nginx/Hatchbox config only allowed 500 sockets.

is there any particular config that I should be paying attention to?

current caddyfile is:

{
  "apps": {
    "http": {
      "servers": {
        "srv0": {
          "listen": [
            ":443",
            ":80"
          ],
          "routes": [
            {
              "handle": [
                {
                  "handler": "subroute",
                  "routes": [
                    {
                      "handle": [
                        {
                          "handler": "vars",
                          "root": "/home/deploy/NanooRemote/current/public"
                        },
                        {
                          "handler": "encode",
                          "encodings": {
                            "gzip": {},
                            "zstd": {}
                          }
                        }
                      ]
                    },
                    {
                      "handle": [
                        {
                          "handler": "reverse_proxy",
                          "upstreams": [
                            {
                              "dial": "127.0.0.1:9000"
                            }
                          ],
                          "trusted_proxies": [
                            <snip>
                          ]
                        }
                      ],
                      "match": [
                        {
                          "not": [
                            {
                              "file": {
                                "try_files": [
                                  "{http.request.uri.path}",
                                  "index.html"
                                ]
                              }
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "handle": [
                        {
                          "handler": "file_server"
                        }
                      ]
                    }
                  ]
                }
              ],
              "match": [
                {
                  "host": [
                    <snip>
                  ]
                }
              ],
              "terminal": true
            }
          ],
          "errors": {
            "routes": [
              {
                "match": [
                  {
                    "host": [
                      <snip>
                    ]
                  }
                ],
                "handle": [
                  {
                    "handler": "subroute",
                    "routes": [
                      {
                        "handle": [
                          {
                            "handler": "headers",
                            "response": {
                              "add": {
                                "Cache-Control": [
                                  "no-cache"
                                ],
                                "expires": [
                                  "0"
                                ]
                              }
                            }
                          }
                        ]
                      },
                      {
                        "handle": [
                          {
                            "handler": "vars",
                            "root": "/home/deploy/.hatchbox/templates"
                          }
                        ]
                      },
                      {
                        "handle": [
                          {
                            "handler": "rewrite",
                            "uri": "/error.html"
                          }
                        ]
                      },
                      {
                        "handle": [
                          {
                            "handler": "file_server"
                          }
                        ]
                      }
                    ]
                  }
                ],
                "terminal": true
              }
            ]
          },
          "tls_connection_policies": null
        }
      }
    },
    "tls": {
      "automation": {
        "policies": [
          {
            "subjects": [
              <snip>
            ],
            "on_demand": true
          }
        ]
      },
      "certificates": {
        "load_files": []
      }
    }
  },
  "logging": {
    "logs": {
      "default": {
        "encoder": {
          "format": "console"
        },
        "level": "info"
      }
    }
  }
}

Nope, it should just work!

Please upgrade to v2.6.2 though, there’s been lots of improvements since.

Make sure to configure the file descriptors limit in Linux to something high enough. The default is often too low and can cause problems.

2 Likes

This topic was automatically closed after 30 days. New replies are no longer allowed.