nats-io / nats.c

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

Request returns error status on callback, rather than from the method itself #740

Open jakeobrien opened 4 months ago

jakeobrien commented 4 months ago

Observed behavior

When calling natsConnection_Request() that results in a Not Permitted error, the error status is not returned from the natsConnection_Request() method. Instead, the Not Permitted status is sent to the callback assigned in natsOptions_SetErrorHandler(). The request method completes with a status of Timeout several seconds after the error callback.

This makes it impossible to tie the error to the request.

An alternative way to do this would be to match the subscription subject in the error callback to the replyID of the request natsMsg handed to the natsConnection_Request() method, but neither of these are populated. The subscription in the callback is empty, and the request given to the request method is also empty when the method times out.

Expected behavior

Ideally, the natsStatus would be returned from the natsConnection_Request() method and it would complete as soon as the error is received.

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