Skip to content

Expose InternalServer as a transport attribute in ServerImpl#12668

Open
vlcekmilan wants to merge 1 commit intogrpc:masterfrom
vlcekmilan:expose-transport-server-attribute
Open

Expose InternalServer as a transport attribute in ServerImpl#12668
vlcekmilan wants to merge 1 commit intogrpc:masterfrom
vlcekmilan:expose-transport-server-attribute

Conversation

@vlcekmilan
Copy link

This change exposes the InternalServer as a transport-level attribute on ServerTransportListenerImpl, making it available to ServerTransportFilter implementations and downstream consumers via Attributes.

Changes

  1. Added a static Attributes.Key named TRANSPORT_SERVER_ATTR with the key "io.grpc.Grpc.TRANSPORT_ATTR_SERVER_TRANSPORT"
  2. In transportReady(), the transportServer reference is set on the Attributes before transport filters are invoked, so it is accessible throughout the request lifecycle

Why
We need access to the underlying ServerTransport from within a ServerInterceptor to force-close the transport connection when an external session expires.

In our use case, we have a ServerInterceptor that authenticates incoming RPCs against an external session management system. When a session isestablished, we register a close handler on it. If the external session is later invalidated or expires, the close handler fires and needs to shut down the underlying transport so the client is forced to reconnect and re-authenticate.

Currently, there is no way for a ServerInterceptor to access the transport layer to force-close a connection. The interceptor can reject individual RPCs via call.close(Status.UNAUTHENTICATED, ...), but it cannot terminate the transport itself.

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Feb 26, 2026

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: vlcekmilan / name: Milan Vlcek (d49ab2f)

@vlcekmilan vlcekmilan force-pushed the expose-transport-server-attribute branch from 6e9994a to 1e53d90 Compare February 26, 2026 12:13
@vlcekmilan vlcekmilan force-pushed the expose-transport-server-attribute branch from 1e53d90 to d49ab2f Compare February 26, 2026 14:48
@vlcekmilan
Copy link
Author

Hello @ejona86, could you pls review this?

@ejona86
Copy link
Member

ejona86 commented Feb 27, 2026

exposes the InternalServer

That's internal. We're definitely not going to expose it directly. We'd have to do something indirectly.

When a session isestablished

How is a session established?

so the client is forced to reconnect and re-authenticate.

Is authentication an RPC, or part of TLS handshake? Or are you doing something with ServerTransportFilter?

@ejona86
Copy link
Member

ejona86 commented Feb 27, 2026

If the external session is later invalidated or expires

FWIW, predictable expiration could potentially be handled by maxConnectionAge(). But if sessions can be suddenly invalidated, that's quite a different thing.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants