Two apps send concurrent notification failing

We have two applications sending notification on stream “NETCONF”. We are registering the notification callback at startup of App.

confd_load_schemas(confd_sock_addr, sizeof(struct sockaddr_in6));
dnctx = confd_init_daemon("swm_notif_deamon"))
confd_notif_ctl_sock = socket(is_ipv6 ? AF_INET6 : AF_INET, SOCK_STREAM, 0)) ;
confd_connect(dnctx, confd_notif_ctl_sock, CONTROL_SOCKET, confd_sock_addr,sizeof(struct sockaddr_in6);
confd_notif_worker_sock = socket(is_ipv6 ? AF_INET6 : AF_INET, SOCK_STREAM, 0);\
confd_connect(dnctx, confd_notif_worker_sock,WORKER_SOCKET, confd_sock_addr,sizeof(struct sockaddr_in6);
notification_handler.fd = confd_notif_worker_sock;
notification_handler.get_log_times = NULL;
notification_handler.replay = NULL;
strcpy(notification_handler.streamname, "NETCONF");
notification_handler.cb_opaque = NULL;
confd_register_notification_stream(dnctx, &notification_handler, &live_ctx) != CONFD_OK;
confd_register_done(dnctx) != CONFD_OK;

But it is failing in different scenarios:

CASE 1:: confd started
App1 is started
App2 is started

before calling confd_notification_send live_ctx values are as follows for App1

live_ctx :: name NETCONF
live_ctx :: fd 7
live_ctx :: live_fd 7
live_ctx :: subid 0
live_ctx :: flags 0
live_ctx :: seen_reply 0

for App2

live_ctx :: name NETCONF
live_ctx :: fd 7
live_ctx :: live_fd 7
live_ctx :: subid 0
live_ctx :: flags 0
live_ctx :: seen_reply 0

but while sending notification from App1 is getting

12-Oct-2021::19:57:00.074 167201/7fe23f4d1700/7 SEND op=15 isrel=0 th=-1 {170,'NETCONF',undefined,{19,{2021,10,12,14,27,0,74720,0,0}},0,
{hxml,[{[1072577735|1539713374],start},{1824330763,#Bin<VALUE(4)....>},{1950810920,{28,0}},{174234492,#Bin<>},{[1072577735|1539713374],stop}]},[]}
Return from confd_notification_send is 0 but no notification came at subscription end

but again if App1 send same notification towards confd

DEBUG Socket to ConfD is closed
Return from confd notification send -2

However App1 able to send notification successfully

CASE 2::confd started
App2 is started
App1 is started

before calling confd_notification_send live_ctx values are as follows for App2

live_ctx :: name NETCONF
live_ctx :: fd 7
live_ctx :: live_fd 7
live_ctx :: subid 0
live_ctx :: flags 0
live_ctx :: seen_reply 0

for App2

live_ctx :: name NETCONF
live_ctx :: fd 7
live_ctx :: live_fd 7
live_ctx :: subid 0
live_ctx :: flags 0
live_ctx :: seen_reply 0

but while sending notification from App2 is getting

12-Oct-2021::19:57:00.074 167201/7fe23f4d1700/7 SEND op=15 isrel=0 th=-1 {170,'NETCONF',undefined,{19,{2021,10,12,14,27,0,74720,0,0}},0,
{hxml,[{[1072577735|1539713374],start},{1824330763,#Bin<VALUE(4)....>},{1950810920,{28,0}},{174234492,#Bin<>},{[1072577735|1539713374],stop}]},[]}

Return from confd_notification_send is 0 but no notification came at subscription end

but again if App2 send same notification towards confd

DEBUG Socket to ConfD is closed
Return from confd notification send -2

However App2 able to send notification successfully

CASE 3:: if we kill failing App and restart it then everything works fine

Golden rule is to use one socket per application/thread. No sharing of sockets between threads.