Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIXED] natsConnection_RequestMsg() incorrectly returns NATS_NO_SERVER_SUPPORT #645

Merged
merged 3 commits into from
Mar 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/pub.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,11 @@ natsConn_publish(natsConnection *nc, natsMsg *msg, const char *reply, bool direc
// accessing the headers. It should still be considered having headers.
if ((msg->headers != NULL) || natsMsg_needsLift(msg))
{
if (!nc->info.headers)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: 0/5 update the comment with the comment from this PR to explain why initc is excluded?

// Do the check for server's headers support only after we have completed
// the initial connect (we could be here with initc true - that is, initial
// connect in progress - when using natsOptions_SetRetryOnFailedConnect
// option).
if (!nc->initc && !nc->info.headers)
{
natsConn_Unlock(nc);

Expand Down
18 changes: 18 additions & 0 deletions test/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -9530,6 +9530,8 @@ test_RetryOnFailedConnect(void)
int64_t end = 0;
natsThread *t = NULL;
natsSubscription *sub = NULL;
natsMsg *msg = NULL;
natsMsg *rmsg = NULL;
struct threadArg arg;

s = _createDefaultThreadArgsForCbTests(&arg);
Expand Down Expand Up @@ -9596,6 +9598,16 @@ test_RetryOnFailedConnect(void)
testCond((s == NATS_NOT_YET_CONNECTED) && (nc != NULL));
nats_clearLastError();

// Request with a message with headers does timeout as opposed to returning
// the NATS_NO_SERVER_SUPPORT error.
test("Request with message with headers: ");
s = natsMsg_Create(&msg, "request.headers", NULL, "hello", 5);
IFOK(s, natsMsgHeader_Set(msg, "some", "header"));
IFOK(s, natsConnection_RequestMsg(&rmsg, nc, msg, 250));
testCond(s == NATS_TIMEOUT);
nats_clearLastError();
natsMsg_Destroy(msg);

test("Subscription ok: ");
arg.control = 99;
s = natsConnection_Subscribe(&sub, nc, "foo", _recvTestString, (void*)&arg);
Expand Down Expand Up @@ -32662,6 +32674,9 @@ test_StanBasicPublish(void)

stanConnection_Destroy(sc);

if (valgrind)
nats_Sleep(900);

_stopServer(pid);
}

Expand Down Expand Up @@ -32719,6 +32734,9 @@ test_StanBasicPublishAsync(void)

_destroyDefaultThreadArgs(&args);

if (valgrind)
nats_Sleep(900);

_stopServer(pid);
}

Expand Down