Skip to content

Leaked OkHttp connection #395

@jonavos

Description

@jonavos

I see this occurring sporadically in my logs.

Mar 18, 2025 5:17:52 PM okhttp3.internal.platform.Platform log
WARNING: A connection to https://connectrpc.example.com/ was leaked. Did you forget to close a response body? To see where this was allocated, set the OkHttpClient
logger level to FINE: Logger.getLogger(OkHttpClient.class.getName()).setLevel(Level.FINE);

I can't currently produce answers as suggested by the log line. I can only produce this issue when running many thousands of connections in a single process (with different OkHttp clients). Which makes tracing a single instance tricky. However I will keep trying.

Some Googling suggests that the response body should be closed even in the even of an exception. I assume that the issue here. Although it's worth noting that I don't see an exception propagating to my client code in these instances.

Thank you.

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