Skip to content

Help on keep-alive connections #3924

@m0dch3n

Description

@m0dch3n

💬 Question here

I have implemented a graceful shutdown, which is waiting for fastify.close() to be executed gracefully.

Because close() does not terminate before a certain timeout when keep-alive connections were made before, my graceful shutdown is not working.

So I added forceCloseConnections: true to the config. Now close() does no longer wait and everything is fine.

HOWEVER my oAuth now breaks the browser session.

To reproduce to break the session:

The browser sends some 'keep-alive' requests to fastify, they all work fine.
The browser then does an oAuth, is redirected to Google for example.
At the end, the browser now comes back, and from that moment on, fastify alway sends no matter what route:

{
error: "Bad Request",
message: "Client Error",
statusCode: 400
}

Opening a second window does also not work. Opening a new window in incognito mode works.

So my assumption is the browser is still trying to use same the keep-alive connection, before it did the oAuth.

During the oAuth fastify is loosing then the reference to this connection, when browser now comes back, the connection is completely broken, and fastify is no longer able to handle ANY request for that connection, because it can no longer associate the request the right keep-alive connection...

I also tried to increase keepAliveTimeout but it did not affect anything...

Your Environment

  • fastify version: >=3.29.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    semver-minorIssue or PR that should land as semver minor

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions