grpc-swift: deadlineExceeded(connectionError: Optional(NIOHTTP2.NIOHTTP2Errors.UnableToParseFrame(file: "NIOHTTP2/HTTP2ChannelHandler.swift", line: 442)))

Hi there, trying below code but got the error: deadlineExceeded(connectionError: Optional(NIOHTTP2.NIOHTTP2Errors.UnableToParseFrame(file: “NIOHTTP2/HTTP2ChannelHandler.swift”, line: 442)))

    func run_Greeting() async throws {
        let group = MultiThreadedEventLoopGroup(numberOfThreads: 1)
        defer {
            try! group.syncShutdownGracefully()
        }
        
        let channel = try GRPCChannelPool.with(
            target: .host(hostUrlString, port: 443),
            transportSecurity: .plaintext,
            eventLoopGroup: group
        )
        
        defer{
            try! channel.close().wait()
        }
        
        let moober = Greet_GreeterApiAsyncClient(channel: channel)
        
        let req = Greet_HelloRequest.with {
            $0.name = "NMaks"
        }
        
        do {
            let resp = try await moober.sayHello(req)
            print("got from server: \(resp.message)")
            dump(resp)
        } catch {
            print("got error: \(error)")
        }

    }

Where to dig?(

About this issue

  • Original URL
  • State: closed
  • Created 10 months ago
  • Comments: 15

Most upvoted comments

You’ll need to:

  • add a dependency on https://github.com/apple/swift-log
  • import Logging
  • create a logger: var logger = Logger(label: "grpc")
  • set the level: logger.logLevel = .trace
  • configure the channel pool:
let channel = try GRPCChannelPool.with(
    target: .host(hostUrlString, port: 443),
    transportSecurity: .plaintext,
    eventLoopGroup: group
) {
  $0.backgroundActivityLogger = logger
}
  • and configure the client:
let options = CallOptions(logger: logger)
let moober = Greet_GreeterApiAsyncClient(channel: channel, defaultCallOptions: options)