ConfD User Community

Can websockets be used for implementing publish subscribe

Does confd support WebSockets?
Can WebSockets be used for implementing the publish-subscribe model?
Is there a javascript library available for the same?
I am using RESTCONF APIs from web app to communicate to confd. I would like to check if I can do a pub-sub model if there are any changes made by other interfaces.

I have read about the comet related implementation in the user guide using JSON_RPC.
As my implementation is around restconf and java script, should i use something like this https://www.pubnub.com/learn/glossary/what-is-comet-programming/

Or can I use the latest websocket programming if confd has support.

No, ConfD doesn’t support WebSockets.

As you discovered, you can use the JSON-RPC API and Comet by for example using the subscribe_change, subscribe_cdboper, etc methods.
An example can be found in the ConfD example set under examples.confd/json_rpc/common_flow

My implementation is around RESTCONF.
So, wanted to know if websockets can be used or should i just continue with some comet related java script library.

You can get notifications for changes made to the configuration using RESTCONF notifications by subscribing to the built-in NETCONF base notifications stream.

For an example go to examples.confd/restconf/notifications and:

$ make all start-builtin
$ % curl -i -X "GET" -H "Accept: text/event-stream" -u admin:admin http://localhost:8008/restconf/streams/NETCONF/json
$ confd_cli -u admin -C 
$ config
(config)$ interfaces interface 1 desc test
(config)$ commit

The config-change notification:

{
  "ietf-restconf:notification": {
    "eventTime": "2020-02-28T08:30:02.846422+01:00",
    "ietf-netconf-notifications:netconf-config-change": {
      "changed-by": {
        "username": "admin",
        "session-id": 0,
        "source-host": "127.0.0.1"
      },
      "datastore": "running",
      "edit": [
        {
          "target": "/notif:interfaces/notif:interface[notif:if-index='1']",
          "operation": "create"
        }
      ]
    }
  }
}