grpc-swift: unavailable (14): Transport became inactive on big response

Describe the bug

  1. I am using the following: 1.1. iOS (Swift) 1.2. Cocoapods
    pod 'gRPC-Swift',          '1.6.1'
    pod 'gRPC-Swift-Plugins',  '1.6.1'
    pod 'SwiftProtobuf',       '1.18.0'
    
  2. I am calling a gRPC that returns approximately 40 MB of data.
let eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: System.coreCount)
return ClientConnection.usingPlatformAppropriateTLS(for: eventLoopGroup).withMaximumReceiveMessageLength(100 * 1024 * 1024).connect(host: host, port: port)

I use default CallOptions.

  1. I have intentionally set the max. length to 100 MB as it otherwise shows an error the default 4MB are exceeded.

  2. What exactly happens - I make the request, for approximately 1 minute it transfers data (seen in the Xcode Debug Navigation) and then it just stays inactive for a long period of time. Then it show the error unavailable (14): Transport became inactive.

  3. A similar request with a response around 400 KB works properly.

Expected behaviour

I expect the API to return the response properly.

Additional information

I also checked the service through a gRPC client (Kreya) and the response is returned properly.

About this issue

Most upvoted comments

Semantically grpc-swift doesn’t have many difference between debug and release. The main semantic difference I can think of are some assertions which exist in debug mode will be runtime errors in release mode, but that’s not related to the problem you’re seeing.

The main difference you’re seeing is that in debug mode grpc-swift and its dependencies will perform additional state checks and the compiler optimisations will not be enabled resulting in much worse performance at runtime than in release mode.

If you use SPM, this is an app-wide setting: so long as you enable compiling in release mode (usually in your Scheme) it will apply to grpc-swift. I don’t know how to do this for Cocoapods I’m afraid.

Are you compiling in release mode? That is, swift build -c release?