# How to get the subscriber status of notification stream

**URL:** https://dmap-community.ductus.global/t/how-to-get-the-subscriber-status-of-notification-stream/3078
**Category:** NETCONF
**Created:** [June 1, 2020, 1:55am UTC](https://dmap-community.ductus.global/t/how-to-get-the-subscriber-status-of-notification-stream/3078 "2020-06-01T01:55:16Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![byu](https://avatars.discourse-cdn.com/v4/letter/b/9fc29f/32.png) [@byu](https://dmap-community.ductus.global/u/byu)
#### Post date: [June 1, 2020, 1:55am UTC](https://dmap-community.ductus.global/t/how-to-get-the-subscriber-status-of-notification-stream/3078/1 "2020-06-01T01:55:16Z")

</div>

1.start thread1, regist notification **stream1** by confd\_register\_notification\_stream() and send event notification by confd\_notification\_send().

1. i start thread2 and use the confd\_notifications\_connect2() and confd\_read\_notification() to subscriber the **stream1** (simulate one subscriber user session )and reveived the related notification from the **stream1**.

2. how the thread1 to get the subscriber status(such as start or stop) of the thread2 subscriber user session?  
(such as: if thread2 start, thread1 could know the **stream1** subscriber session is ready, if thread2 exit, the **stream1** subscriber is not ready.)

need support on this,

thx

---

<div class="post-metadata">

### Author: ![cohult](https://yyz2.discourse-cdn.com/flex010/user_avatar/dmap-community.ductus.global/cohult/32/221_2.png) [@cohult](https://dmap-community.ductus.global/u/cohult)
#### Post date: [June 1, 2020, 6:55am UTC](https://dmap-community.ductus.global/t/how-to-get-the-subscriber-status-of-notification-stream/3078/2 "2020-06-01T06:55:36Z")

</div>

See `$CONFD_DIR/src/confd/yang/tailf-netconf-monitoring.yang`  
look for `start-time` and `stop-time`

Example using MAAPI:

```xml
$ confd_load -dd -Fp -o -p /ncm:netconf-state/tncm:streams/tncm:stream
TRACE Connected (maapi) to ConfD
starting user session ctxt=system user=system groups=[system]
TRACE MAAPI_START_USER_SESSION --> CONFD_OK
TRACE MAAPI_START_TRANS --> CONFD_OK
TRACE MAAPI_SAVE_CONFIG --> CONFD_OK
TRACE Connected (stream) to ConfD
<config xmlns="http://tail-f.com/ns/config/1.0">
  <netconf-state xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring">
  <streams xmlns="http://tail-f.com/yang/netconf-monitoring">
  <stream>
    <name>NETCONF</name>
    <description>default NETCONF event stream</description>
    <replay-support>false</replay-support>
  </stream>
  <stream>
    <name>interface</name>
    <description>Example notifications</description>
    <replay-support>true</replay-support>
    <replay-log-creation-time>2020-06-01T06:38:01.931789+00:00</replay-log-creation-time>
    <subscriber>
      <session-id>1</session-id>
      <start-time>2020-06-01T08:38:17.931283+02:00</start-time>
    </subscriber>
    <subscriber>
      <session-id>2</session-id>
      <start-time>2020-06-01T08:38:22.774519+02:00</start-time>
    </subscriber>
    <subscriber>
      <session-id>3</session-id>
      <start-time>2020-06-01T08:40:04.23751+02:00</start-time>
    </subscriber>
    <subscriber>
      <session-id>4</session-id>
      <start-time>2020-06-01T08:42:03.162586+02:00</start-time>
    </subscriber>
    <subscriber>
      <session-id>5</session-id>
      <start-time>2020-06-01T09:03:42.21049+02:00</start-time>
    </subscriber>
  </stream>
  </streams>
  </netconf-state>
TRACE MAAPI_SAVE_CONFIG_RESULT --> CONFD_OK
</config>
TRACE MAAPI_END_USER_SESSION --> CONFD_OK

```

Best regards,  
Conny

---

<div class="post-metadata">

### Author: ![byu](https://avatars.discourse-cdn.com/v4/letter/b/9fc29f/32.png) [@byu](https://dmap-community.ductus.global/u/byu)
#### Post date: [June 1, 2020, 7:15am UTC](https://dmap-community.ductus.global/t/how-to-get-the-subscriber-status-of-notification-stream/3078/3 "2020-06-01T07:15:25Z")

</div>

thanks your quick response,  
can u share the relate Maapi C/C++ example to me?

---

<div class="post-metadata">

### Author: ![byu](https://avatars.discourse-cdn.com/v4/letter/b/9fc29f/32.png) [@byu](https://dmap-community.ductus.global/u/byu)
#### Post date: [June 1, 2020, 9:46am UTC](https://dmap-community.ductus.global/t/how-to-get-the-subscriber-status-of-notification-stream/3078/4 "2020-06-01T09:46:26Z")

</div>

path= “/ncm:netconfstate/tncm:streams/tncm:stream{evmserver}”;  
maapi\_get\_list\_elem(mCandidateDbSocket, mTransId, &list,&number, “%s”, path);

i use the above API want to get some info, but it seems input an invalid path, which path should be used?

error log:

TRACE MAAPI\_START\_TRANS --\> CONFD\_OK  
TRACE MAAPI\_GET\_ELEM /ncm:netconf-state/tncm:streams/tncm:stream{evmserver}DEBUG badly formatted or nonexistent path -  
–\> CONFD\_ERR

if use confd\_load cmd, it will:

[root@0-9 bin]# ./confd\_load -dd -Fp -o -p /ncm:netconf-state/tncm:streams/tncm:stream{evmserver}  
TRACE Connected (maapi) to ConfD  
starting user session ctxt=system user=system groups=[system]  
TRACE MAAPI\_START\_USER\_SESSION --\> CONFD\_OK  
TRACE MAAPI\_START\_TRANS --\> CONFD\_OK  
TRACE MAAPI\_SAVE\_CONFIG --\> CONFD\_OK  
TRACE Connected (stream) to ConfD  
  
  
  
  
evmserver  
evmserver notifications  
true  
2020-05-14T17:29:51.331351+00:00  
  
21  
2020-06-01T22:09:15.234266+05:30  
  
  
  
  
TRACE MAAPI\_SAVE\_CONFIG\_RESULT --\> CONFD\_OK  
  
TRACE MAAPI\_END\_USER\_SESSION --\> CONFD\_OK

how to set path for it?please hlep me.

---

<div class="post-metadata">

### Author: ![cohult](https://yyz2.discourse-cdn.com/flex010/user_avatar/dmap-community.ductus.global/cohult/32/221_2.png) [@cohult](https://dmap-community.ductus.global/u/cohult)
#### Post date: [June 1, 2020, 6:25pm UTC](https://dmap-community.ductus.global/t/how-to-get-the-subscriber-status-of-notification-stream/3078/5 "2020-06-01T18:25:36Z")

</div>

The source code for the confd\_load tool comes with ConfD:  
`$CONFD\_DIR/src/confd/tools/confd\_load.c

You can also use the confd\_cmd tool that can use maapi\_get\_objects() to get the list:  
`$ confd_cmd -dd -o -c 'traverse_list "/netconf-state/streams/stream{interface}/subscriber"'`

The source code for the confd\_cmd tool can be found in the same folder as the confd\_load tool.  
`$CONFD_DIR/src/confd/tools/confd_cmd.c`

---

<div class="post-metadata">

### Author: ![byu](https://avatars.discourse-cdn.com/v4/letter/b/9fc29f/32.png) [@byu](https://dmap-community.ductus.global/u/byu)
#### Post date: [June 2, 2020, 7:21am UTC](https://dmap-community.ductus.global/t/how-to-get-the-subscriber-status-of-notification-stream/3078/6 "2020-06-02T07:21:40Z")

</div>

ok，  
Is there other event mechnism **automatically**? when thread2 start and subscriber this stream, thread1 can get it right now. when the subscriber is exist(thread2 exist), thread1 can know it right now.

for below case:

1.start thread1, regist notification **stream1** by confd\_register\_notification\_stream() and send event notification by confd\_notification\_send().

1. i start thread2 and use the confd\_notifications\_connect2() and confd\_read\_notification() to subscriber the **stream1** (simulate one subscriber user session )and reveived the related notification from the **stream1**

thx

---

<div class="post-metadata">

### Author: ![cohult](https://yyz2.discourse-cdn.com/flex010/user_avatar/dmap-community.ductus.global/cohult/32/221_2.png) [@cohult](https://dmap-community.ductus.global/u/cohult)
#### Post date: [June 2, 2020, 9:56am UTC](https://dmap-community.ductus.global/t/how-to-get-the-subscriber-status-of-notification-stream/3078/7 "2020-06-02T09:56:32Z")

</div>

Do you mean getting a notification when someone register for a NETCONF stream notification using the ConfD event notification API?  
If so I believe that you can’t subscribe to those changes, and that you need to poll.

Example using the confd\_cmd tool:

```auto
ecode=1; while [$ecode -ne 0]; do sleep .5; confd_cmd -o -c "mget /netconf-state/streams/stream{interface}/subscriber{1}/session-id" > /dev/null; ecode=$?; done;

```

---

<div class="post-metadata">

### Author: ![byu](https://avatars.discourse-cdn.com/v4/letter/b/9fc29f/32.png) [@byu](https://dmap-community.ductus.global/u/byu)
#### Post date: [June 4, 2020, 1:21am UTC](https://dmap-community.ductus.global/t/how-to-get-the-subscriber-status-of-notification-stream/3078/8 "2020-06-04T01:21:46Z")

</div>

thanks for your response.  
it seems need application code to do subscriber status polling.  
for the standard notificaiton subscriber method(use netconf protocol to subscriber), we can get the user session status(START or STOP) by notificaiton event(CONFD\_NOTIF\_USER\_SESSION - Whenever a user session is started or stopped).  
Can we have some methods to get the user session status automatically like the above CONFD\_NOTIF\_USER\_SESSION event.(attention: we use confd\_notifications\_connect2() and confd\_read\_notification() API to subscriber NETCONF stream)  
thanks for your help.

---

<div class="post-metadata">

### Author: ![cohult](https://yyz2.discourse-cdn.com/flex010/user_avatar/dmap-community.ductus.global/cohult/32/221_2.png) [@cohult](https://dmap-community.ductus.global/u/cohult)
#### Post date: [June 4, 2020, 9:07am UTC](https://dmap-community.ductus.global/t/how-to-get-the-subscriber-status-of-notification-stream/3078/9 "2020-06-04T09:07:38Z")

</div>

> Can we have some methods to get the user session status automatically like the above CONFD\_NOTIF\_USER\_SESSION event.(attention: we use confd\_notifications\_connect2() and confd\_read\_notification() API to subscriber NETCONF stream)

Instead, when your notification stream subscriber application registers using confd\_notifications\_connect2(), the notification stream subscriber application can at the same time add itself to a list of subscribers in the CDB operational datastore by, for example, reusing the stream subscriber list from the `$CONFD_DIR/src/confd/yang/tailf-netconf-monitoring.yang` model.

Then you do a cdb\_oper\_subscribe() to the subscriber list from your application that send notifications.

See examples.confd/cdb\_oper/subcriber for an example of writing to the CDB operational datastore and subscribing to updates. A performance demo can be found here: [ConfD-Demos/oper-performance at master · ConfD-Developer/ConfD-Demos · GitHub](https://github.com/ConfD-Developer/ConfD-Demos/tree/master/oper-performance)
