Skip to content

collaboration: connection leak in GetAppURLs, one connection per discovery fetch (every 30 s by default) #3901

Open

Description

@igorski89

Describe the bug

GetAppURLs (services/collaboration/pkg/helpers/discovery.go) creates a new http.Client with a new http.Transport on every call. It closes the response body but never the transport's idle connection, and the transport has no IdleConnTimeout. The connection stays open until the server closes it.

The call runs in a loop every COLLABORATION_CS3API_APP_REGISTRATION_INTERVAL (default 30 s, services/collaboration/pkg/command/server.go). So the service gains about 2,880 idle connections per day when the WOPI app, or a reverse proxy in front of it, doesn't close idle connections.

Impact we saw

Seen on 7.2.4 (single binary, OC_ADD_RUN_SERVICES=collaboration), with COLLABORATION_APP_ADDR pointing at Collabora's public HTTPS address through a reverse proxy that had no idle timeout (kamal-proxy before v0.10.2):

  • After 9.8 days the process held 28,231 established connections to that address, all idle. The Linux ephemeral port range is 28,232 ports.
  • Container memory grew by about 160 MB per day, from about 1 GB to 1.8 GB.
  • Once the source ports ran out, new connections on that path were reset, including those of other containers on the host. Discovery fetches then failed too. Because the loop stores an empty map on failure, the app URLs are cleared until a later fetch succeeds.

Steps to reproduce

  1. Run the collaboration service with COLLABORATION_APP_ADDR pointing at a server or proxy that keeps idle HTTP/1.1 connections open indefinitely.
  2. Count established connections from the OpenCloud process to that address every few minutes, e.g. ss -tnp state established.

Expected behavior

The number of connections stays constant: the periodic fetch reuses one connection or closes it after each call.

Actual behavior

One more established connection every interval. On the proxy side, each one had sent about 54 KB (one discovery response) and then stayed idle.

Suggested fix

Either reuse a single long-lived http.Client, or add this after creating the client in GetAppURLs:

defer httpClient.CloseIdleConnections()

Setting IdleConnTimeout on the transport would also bound it.

The same per-call http.Transport pattern is in services/collaboration/pkg/proofkeys/handler.go (fetchPublicKeys) and services/collaboration/pkg/connector/contentconnector.go. We didn't measure leaks there, and those paths run less often.

Versions

Observed on 7.2.4. As of 2026-11-04 the same GetAppURLs code is in v9.0.0 and on main.

Workaround

A longer COLLABORATION_CS3API_APP_REGISTRATION_INTERVAL slows the leak, at the cost of slower recovery of the app URLs after a failed fetch. Restarting the service releases the connections.

Activity

  1. RyoKusnadi commented on Nov 4, 2026

    @RyoKusnadi
    Contributor

    @rhafer I opened #3902 for this. Could you please review it when you have a moment? Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions