grpc/grpc-swift

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

NMaks07 opened this issue · 15 comments

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?(

and what below error means? How to locate reason?

deadlineExceeded(connectionError: Optional(NIOPosix.NIOConnectionError(host: hostUrlString, port: 443, dnsAError: Optional(NIOCore.SocketAddressError.unknown(host: "somehost", port: 443)), dnsAAAAError: Optional(NIOCore.SocketAddressError.unknown(host: "somehost", port: 443)), connectionErrors: [])))

Lukasa commented

This error means that the DNS lookups for somehost failed.

This error means that the DNS lookups for somehost failed.

But when in browser I go to the https://somehost:443 it shows me
Communication with gRPC endpoints must be made through a gRPC client. To learn how to create a client, visit: https://go.microsoft.com/fwlink/?linkid=2086909

I guess this means grpc service is running and waits client requests at https://somehost:443.
I am stuck and, don't know where to dig

What is hostUrlString? somehost or https://somehost?

https://somehost

Lukasa commented

Are you running on the exact same machine as the browser? What browser are you using? Do you have a VPN enabled?

Are you running on the exact same machine as the browser? What browser are you using? Do you have a VPN enabled?

Yes, my real phone. Browser Safari, no any vpn. In ios simulator doesn't work neither

Lukasa commented

Are you also running this in an iOS app? Do you have appropriate permissions to do client networking on the phone?

Are you also running this in an iOS app? Do you have appropriate permissions to do client networking on the phone?

Yes, it's the iOS app. App have network permission on iOS device.
can I DM you, and maybe give you access to my laptop through AnyDesk?

Lukasa commented

Can you provide full logs please? Attach a background activity logger to the GRPCChannelPool and then also set a logger on the CallOptions for your specific call. Make sure both loggers have a log level set to debug. Then can you send the results?

Can you provide full logs please? Attach a background activity logger to the GRPCChannelPool and then also set a logger on the CallOptions for your specific call. Make sure both loggers have a log level set to debug. Then can you send the results?

Thank you for your assistance.
I am afraid I don't know how to enable loggers, can you show me? 🙏

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)

Can you provide full logs please? Attach a background activity logger to the GRPCChannelPool and then also set a logger on the CallOptions for your specific call. Make sure both loggers have a log level set to debug. Then can you send the results?

2023-09-09T19:40:34+0500 debug GRPCChannelPool_LOGGER : poolmanager.id=ObjectIdentifier(0x000060000274c1c0) poolmanager.pools.conns_per_pool=1 poolmanager.pools.count=1 poolmanager.pools.waiters_per_pool=100 [GRPC] initializing connection pool manager
2023-09-09T19:40:34+0500 debug GRPCChannelPool_LOGGER : pool.reservations.capacity=0 pool.reservations.count=1 pool.reservations.load=inf pool.reservations.loadThreshold=0.9 poolmanager.id=ObjectIdentifier(0x000060000274c1c0) [GRPC] stream reservation load factor greater than or equal to threshold, bringing up additional connection if available
2023-09-09T19:40:34+0500 debug GRPCChannelPool_LOGGER : grpc_connection_id=DFEECFFF-B287-43B9-9E07-C467EAE699B9/0 poolmanager.id=ObjectIdentifier(0x000060000274c1c0) [GRPC] making client bootstrap with event loop group of type SelectableEventLoop
2023-09-09T19:40:34+0500 debug GRPCChannelPool_LOGGER : grpc_connection_id=DFEECFFF-B287-43B9-9E07-C467EAE699B9/0 poolmanager.id=ObjectIdentifier(0x000060000274c1c0) [GRPC] Network.framework is available but the EventLoopGroup is not compatible with NIOTS, falling back to ClientBootstrap
2023-09-09T19:40:34+0500 debug GRPCChannelPool_LOGGER : grpc_connection_id=DFEECFFF-B287-43B9-9E07-C467EAE699B9/0 poolmanager.id=ObjectIdentifier(0x000060000274c1c0) [GRPC] creating a ClientBootstrap
2023-09-09T19:40:34+0500 debug GRPCChannelPool_LOGGER : delay=1.0 grpc_connection_id=DFEECFFF-B287-43B9-9E07-C467EAE699B9/0 poolmanager.id=ObjectIdentifier(0x000060000274c1c0) [GRPC] scheduling connection attempt
2023-09-09T19:40:35+0500 debug GRPCChannelPool_LOGGER : grpc_connection_id=DFEECFFF-B287-43B9-9E07-C467EAE699B9/1 poolmanager.id=ObjectIdentifier(0x000060000274c1c0) [GRPC] making client bootstrap with event loop group of type SelectableEventLoop
2023-09-09T19:40:35+0500 debug GRPCChannelPool_LOGGER : grpc_connection_id=DFEECFFF-B287-43B9-9E07-C467EAE699B9/1 poolmanager.id=ObjectIdentifier(0x000060000274c1c0) [GRPC] Network.framework is available but the EventLoopGroup is not compatible with NIOTS, falling back to ClientBootstrap
2023-09-09T19:40:35+0500 debug GRPCChannelPool_LOGGER : grpc_connection_id=DFEECFFF-B287-43B9-9E07-C467EAE699B9/1 poolmanager.id=ObjectIdentifier(0x000060000274c1c0) [GRPC] creating a ClientBootstrap
2023-09-09T19:40:35+0500 debug GRPCChannelPool_LOGGER : delay=1.5741590859255932 grpc_connection_id=DFEECFFF-B287-43B9-9E07-C467EAE699B9/1 poolmanager.id=ObjectIdentifier(0x000060000274c1c0) [GRPC] scheduling connection attempt
2023-09-09T19:40:37+0500 debug GRPCChannelPool_LOGGER : grpc_connection_id=DFEECFFF-B287-43B9-9E07-C467EAE699B9/2 poolmanager.id=ObjectIdentifier(0x000060000274c1c0) [GRPC] making client bootstrap with event loop group of type SelectableEventLoop
2023-09-09T19:40:37+0500 debug GRPCChannelPool_LOGGER : grpc_connection_id=DFEECFFF-B287-43B9-9E07-C467EAE699B9/2 poolmanager.id=ObjectIdentifier(0x000060000274c1c0) [GRPC] Network.framework is available but the EventLoopGroup is not compatible with NIOTS, falling back to ClientBootstrap
2023-09-09T19:40:37+0500 debug GRPCChannelPool_LOGGER : grpc_connection_id=DFEECFFF-B287-43B9-9E07-C467EAE699B9/2 poolmanager.id=ObjectIdentifier(0x000060000274c1c0) [GRPC] creating a ClientBootstrap
2023-09-09T19:40:37+0500 debug GRPCChannelPool_LOGGER : delay=2.2927322660805465 grpc_connection_id=DFEECFFF-B287-43B9-9E07-C467EAE699B9/2 poolmanager.id=ObjectIdentifier(0x000060000274c1c0) [GRPC] scheduling connection attempt
2023-09-09T19:40:39+0500 debug GRPCChannelPool_LOGGER : grpc_connection_id=DFEECFFF-B287-43B9-9E07-C467EAE699B9/3 poolmanager.id=ObjectIdentifier(0x000060000274c1c0) [GRPC] making client bootstrap with event loop group of type SelectableEventLoop
2023-09-09T19:40:39+0500 debug GRPCChannelPool_LOGGER : grpc_connection_id=DFEECFFF-B287-43B9-9E07-C467EAE699B9/3 poolmanager.id=ObjectIdentifier(0x000060000274c1c0) [GRPC] Network.framework is available but the EventLoopGroup is not compatible with NIOTS, falling back to ClientBootstrap
2023-09-09T19:40:39+0500 debug GRPCChannelPool_LOGGER : grpc_connection_id=DFEECFFF-B287-43B9-9E07-C467EAE699B9/3 poolmanager.id=ObjectIdentifier(0x000060000274c1c0) [GRPC] creating a ClientBootstrap
2023-09-09T19:40:39+0500 debug GRPCChannelPool_LOGGER : delay=4.344797568068027 grpc_connection_id=DFEECFFF-B287-43B9-9E07-C467EAE699B9/3 poolmanager.id=ObjectIdentifier(0x000060000274c1c0) [GRPC] scheduling connection attempt
2023-09-09T19:40:44+0500 debug GRPCChannelPool_LOGGER : grpc_connection_id=DFEECFFF-B287-43B9-9E07-C467EAE699B9/4 poolmanager.id=ObjectIdentifier(0x000060000274c1c0) [GRPC] making client bootstrap with event loop group of type SelectableEventLoop
2023-09-09T19:40:44+0500 debug GRPCChannelPool_LOGGER : grpc_connection_id=DFEECFFF-B287-43B9-9E07-C467EAE699B9/4 poolmanager.id=ObjectIdentifier(0x000060000274c1c0) [GRPC] Network.framework is available but the EventLoopGroup is not compatible with NIOTS, falling back to ClientBootstrap
2023-09-09T19:40:44+0500 debug GRPCChannelPool_LOGGER : grpc_connection_id=DFEECFFF-B287-43B9-9E07-C467EAE699B9/4 poolmanager.id=ObjectIdentifier(0x000060000274c1c0) [GRPC] creating a ClientBootstrap
2023-09-09T19:40:44+0500 debug GRPCChannelPool_LOGGER : delay=7.526069439257019 grpc_connection_id=DFEECFFF-B287-43B9-9E07-C467EAE699B9/4 poolmanager.id=ObjectIdentifier(0x000060000274c1c0) [GRPC] scheduling connection attempt
2023-09-09T19:40:51+0500 debug GRPCChannelPool_LOGGER : grpc_connection_id=DFEECFFF-B287-43B9-9E07-C467EAE699B9/5 poolmanager.id=ObjectIdentifier(0x000060000274c1c0) [GRPC] making client bootstrap with event loop group of type SelectableEventLoop
2023-09-09T19:40:51+0500 debug GRPCChannelPool_LOGGER : grpc_connection_id=DFEECFFF-B287-43B9-9E07-C467EAE699B9/5 poolmanager.id=ObjectIdentifier(0x000060000274c1c0) [GRPC] Network.framework is available but the EventLoopGroup is not compatible with NIOTS, falling back to ClientBootstrap
2023-09-09T19:40:51+0500 debug GRPCChannelPool_LOGGER : grpc_connection_id=DFEECFFF-B287-43B9-9E07-C467EAE699B9/5 poolmanager.id=ObjectIdentifier(0x000060000274c1c0) [GRPC] creating a ClientBootstrap
2023-09-09T19:40:51+0500 debug GRPCChannelPool_LOGGER : delay=9.042634918031531 grpc_connection_id=DFEECFFF-B287-43B9-9E07-C467EAE699B9/5 poolmanager.id=ObjectIdentifier(0x000060000274c1c0) [GRPC] scheduling connection attempt
2023-09-09T19:41:00+0500 debug GRPCChannelPool_LOGGER : grpc_connection_id=DFEECFFF-B287-43B9-9E07-C467EAE699B9/6 poolmanager.id=ObjectIdentifier(0x000060000274c1c0) [GRPC] making client bootstrap with event loop group of type SelectableEventLoop
2023-09-09T19:41:00+0500 debug GRPCChannelPool_LOGGER : grpc_connection_id=DFEECFFF-B287-43B9-9E07-C467EAE699B9/6 poolmanager.id=ObjectIdentifier(0x000060000274c1c0) [GRPC] Network.framework is available but the EventLoopGroup is not compatible with NIOTS, falling back to ClientBootstrap
2023-09-09T19:41:00+0500 debug GRPCChannelPool_LOGGER : grpc_connection_id=DFEECFFF-B287-43B9-9E07-C467EAE699B9/6 poolmanager.id=ObjectIdentifier(0x000060000274c1c0) [GRPC] creating a ClientBootstrap
2023-09-09T19:41:00+0500 debug GRPCChannelPool_LOGGER : delay=17.13268843144522 grpc_connection_id=DFEECFFF-B287-43B9-9E07-C467EAE699B9/6 poolmanager.id=ObjectIdentifier(0x000060000274c1c0) [GRPC] scheduling connection attempt
got error: deadlineExceeded(connectionError: Optional(NIOPosix.NIOConnectionError(host: "https://api.ubee.pro", port: 443, dnsAError: Optional(NIOCore.SocketAddressError.unknown(host: "https://api.ubee.pro", port: 443)), dnsAAAAError: Optional(NIOCore.SocketAddressError.unknown(host: "https://api.ubee.pro", port: 443)), connectionErrors: [])))
2023-09-09T19:41:04+0500 debug GRPCChannelPool_LOGGER : poolmanager.id=ObjectIdentifier(0x000060000274c1c0) [GRPC] shutting down connection pool
2023-09-09T19:41:04+0500 debug GRPCChannelPool_LOGGER : connectivity_state=transientFailure grpc_connection_id=DFEECFFF-B287-43B9-9E07-C467EAE699B9/7 poolmanager.id=ObjectIdentifier(0x000060000274c1c0) shutdown.mode=forceful [GRPC] shutting down connection

What is hostUrlString? somehost or https://somehost?

I have just found out that https://somehost does not work. In order for it to work a host must be without https:// prefix. Is that designed behavior or a bug?

Lukasa commented

This is designed behaviour: https://somehost is a URL, not a hostname.