nats-io / nats.c

A C client for NATS
Apache License 2.0
382 stars 132 forks source link

natsOptions_SetTimeout() not being respected under certain conditions #723

Open jakeobrien opened 5 months ago

jakeobrien commented 5 months ago

Observed behavior

When testing with a very poor network, setting a connection timeout with natsOptions_SetTimeout() is not being respected. Regardless of what I set in milliseconds, the connection times out consistently at 30 seconds per server.

I am using iOS's Network Link Conditioner to simulate a very poor network with 100% packet loss.

The timeout is respected when testing with radios disabled (airplane mode).

For testing purposes, I set natsOptions_SetRetryOnFailedConnect() to false and set a callback there, which is not being called. So, no connection retries should be happening.

Other options are being respected, so I do not believe it is an issue setting options.

Expected behavior

The timeout should be respected. For example setting natsOptions_SetTimeout(opts, 5000) should time out after 10 seconds with two servers.

Server and client version

nats-server: v2.10.3 nats.c client: v3.7.0

Host environment

Client is on various configurations of iPhone hardware and iOS version (recent).

Steps to reproduce

Timeout will not trigger for 30 seconds after initiating the connection attempt.