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

Errno Variable getting set after calling js_PullSubscribe method from nats.c client #795

Open
sudojha opened this issue Sep 4, 2024 · 0 comments
Assignees
Labels
defect Suspected defect such as a bug or regression

Comments

@sudojha
Copy link

sudojha commented Sep 4, 2024

Observed behavior

Once a connection is made to the nats server and a pull subscription is created using the js_PullSubscribe method, the errno (provided by errno.h) gets set to code 84 (EOVERFLOW : Value too large to be stored in data type).

Expected behavior

errno should not be set to a value post js_PullSubscribe call.

Server and client version

I have compiled the nats c client from source code (main branch) and using it in my c project.
Server version: 2.10.18

Host environment

Host env: MacOs Sonoma 14.4

Steps to reproduce

Here's a sample code to reproduce the above behaviour:

#include <iostream>
extern "C" {
#include <nats/nats.h>
}

int main()
{
    natsStatus status;
    natsConnection *conn = nullptr;

    // Initialize the NATS client
    status = natsConnection_ConnectTo(&conn, "nats://localhost:4222");
    if (status != NATS_OK) {
        std::cerr << "Error connecting to NATS: " << natsStatus_GetText(status) << std::endl;
        return 1;
    }

    natsSubscription *sub = NULL;
    jsSubOptions opts;
    status = jsSubOptions_Init(&opts);
    if(status != NATS_OK) {
        perror(natsStatus_GetText(status));
    }
    opts.Consumer = "pull_consumer";
    jsCtx *jetStreamContext = nullptr;
    natsConnection_JetStream(&jetStreamContext,conn,NULL);
    jsSubOptions subOpts;
    status = jsSubOptions_Init(&subOpts);
    if(status != NATS_OK) {
        perror(natsStatus_GetText(status));
    }
    opts.Consumer = "pull_consumer";
    subOpts.Config.AckPolicy = js_AckExplicit;
    natsSubscription *ns = nullptr;
    perror("error before js_PullSubscribe");
    status = js_PullSubscribe(&ns,jetStreamContext,"foo","pull_consumer",NULL,&subOpts,nullptr);
    if (status != NATS_OK) {
        perror("error while pull subscription");
    }
    perror("error after js_PullSubscribe");

    // Clean up
    natsSubscription_Destroy(ns);
    natsConnection_Destroy(conn);
    nats_Close();

    return 0;
}

This consistently results in the following output:

error before js_PullSubscribe: Resource temporarily unavailable
error after js_PullSubscribe: Value too large to be stored in data type

Process finished with exit code 0

While it has no direct impact on the functioning of the library, it could be an indicator of some underlying issue.

@sudojha sudojha added the defect Suspected defect such as a bug or regression label Sep 4, 2024
@levb levb self-assigned this Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
defect Suspected defect such as a bug or regression
Projects
None yet
Development

No branches or pull requests

2 participants