nats-io / nats.c

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

nats c client hanging forever on natsConnection_PublishString #761

Open edmundsj opened 2 months ago

edmundsj commented 2 months ago

Observed behavior

It appears that sometimes when I call natsConnection_PublishString, it hangs forever. I cannot kill the program with SIGINT (Ctrl + C) and it never returns control flow to the main program. What could potentially cause this? My understanding was that all publish methods are asynchronous, and they simply place the message into a queue to be published by a separate thread.

Expected behavior

I expect the method not to hang under any circumstances, and just to return immediately.

Server and client version

Client version: 3.7.1 Server version: v2.10.7-linux-amd64.

Host environment

Centos 8 + Centos 9 (replicable across both)

Steps to reproduce

No response

kozlovic commented 2 months ago

@edmundsj If the internal buffer is full, the library will perform the socket write in place, but in any case, it is strange that you can't interrupt the program. Maybe if you could build in debug mode and attach a debugger when that happens or produce a stack trace that could help determine where the library is stuck?