nats.c icon indicating copy to clipboard operation
nats.c copied to clipboard

natsOptions_SetTimeout() not being respected under certain conditions

Open jakeobrien opened this issue 1 year ago • 0 comments

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

  • Launch Nats client with normally connected network and connection timeout set to 5s per server
  • Connect to Nats server to ensure it is responding
  • Disconnect
  • Set Network Link Conditioner to 100% packet loss
  • Attempt to connect to server

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

jakeobrien avatar Mar 10 '24 23:03 jakeobrien