connectrpc / connect-swift

The Swift implementation of Connect: Protobuf RPC that works.
https://connectrpc.com/docs/swift/getting-started
Apache License 2.0
97 stars 20 forks source link

Inconsistent Timeout Behavior in gRPC with NIOHTTPClient #259

Closed davidweissler closed 6 months ago

davidweissler commented 6 months ago

Hi,

We are encountering an issue with the timeout setting in NIOHTTPClient when used with gRPC. We have configured a timeout of 30 seconds for requests, expecting that any request exceeding this duration should automatically timeout. However, this behavior is inconsistent and hard to reproduce.

Details:

Environment: The issue occurs on iOS 16 and iOS 17, across both iPhone and iPad devices. Version: Connect 0.12.0. Issue: Requests occasionally do not timeout after 30 seconds as expected. Current Workaround: Implemented a manual timeout mechanism that cancels the request at 35 seconds, with these incidents specifically logged. Configuration: Using .grpc for networkProtocol and JSONCodec() for codec.

Question: Are there any known issues with request timeouts in gRPC using NIOHTTPClient that could be causing this behavior? Could you provide guidance on ensuring the timeout setting is consistently respected? Is there a specific configuration tweak required?

Thank you for any help and let me know if there's other info I can provide.

rebello95 commented 6 months ago

👋🏽 Hi @davidweissler - thank you for the detailed information. How are you setting the timeout today and how did you implement the manual 35 second timeout?

Can you try upgrading to 0.13.0? That version added support for a timeout argument on ProtocolClientConfig which sets the header expected by gRPC services, so I'm curious if that fixes it for you.

davidweissler commented 6 months ago

It seems like 0.13.0 fixes the issue we're seeing. I'm going to close this issue, but will reopen / make a new issue if I see odd behavior around timeout. @rebello95 Thanks for pointing to the update.