Skip to content

Cause and mitigation for "Client has been stopped. Can't make any more RPCs." error #25

@alex-vasenin

Description

@alex-vasenin

Most of the times GRPC works reliably in our app, however in rare cases I noticed this error "Client has been stopped. Can't make any more RPCs." after which the client becomes unusable.

What might be causing this error? I'm not stopping the client manually and network errors doesn't seem to cause it (I don't have a way to reproduce).

It seems like I should be ready to recreate GRPC client (and all service clients that wraps it) if it stops for whatever reason. What should be my approach to make sure my service clients are always usable? Is it true that if client is stopped try await client.runConnections() should complete? Do I need to recreate TransportServices as well?

Here is my client init code for reference:

    final class Service {        
        static let grpcClient = {
            let client = GRPCClient(transport: transport,
                                    interceptors: [authInterceptor, loggingInterceptor])
            Task { try! await client.runConnections() } // Runs indefinetly
            return client
        }()
        
        private static let authInterceptor = AuthInterceptor()
        private static let loggingInterceptor = LoggingInterceptor()
        
        private static let transport = try! Transport(target: target, transportSecurity: .tls)
        typealias Transport = HTTP2ClientTransport.TransportServices
        
        private static let target: any ResolvableTarget = .dns(host: AppConfig.grpcHost)
    }

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