CiscoDevNet / yangsuite

Cisco YANG Suite provides a set of tools and plugins to learn, test, and adopt YANG programmable interfaces such as NETCONF, RESTCONF, gNMI and more.
Other
246 stars 76 forks source link

How to cancel the automatic sending of 'close-session' by NETCONF? #93

Closed rydy closed 1 year ago

rydy commented 1 year ago

Hi,

I refer to NETCONF RFC 5277 Notification Streams to run the notification test . The current master branch will automatically send 'close-session' after sending 'create-subscription', which makes me unable to receive relevant notifications. How to cancel the automatic sending of 'close-session'?

log.txt:

   Start Session
Datastores: 

Candidate

Running

Startup
Actions:

Waiting for Data...
No session found. Creating a new temporary session
Sending:
<nc:hello xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">...</nc:hello>
]]>]]>
Received message from host
initialized: session-id=52 | server_capabilities=<dict_keyiterator object at 0x7f5ef431b270>
NETCONF CONNECTED 172.19.3.183:830
NETCONF SEND rpc
Requesting 'Dispatch'
Sending:

#337
<nc:rpc xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:4d9e13cb-1fab-46d6-a9f1-805ec91becee"><nc:get>
    <nc:filter type="subtree">
      <netconf xmlns="urn:ietf:params:xml:ns:netmod:notification">
        <streams/>
      </netconf>
    </nc:filter>
  </nc:get>
</nc:rpc>

##
Received message from host
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:4d9e13cb-1fab-46d6-a9f1-805ec91becee">
  <data>
    <netconf xmlns="urn:ietf:params:xml:ns:netmod:notification">
      <streams>
        <stream>
          <name>NETCONF</name>
          <description>Default NETCONF stream containing notifications from all the modules. Replays only notifications for modules (streams) that support replay.</description>
          <replaySupport>true</replaySupport>
        </stream>
        <stream>
          <name>ietf-yang-library</name>
          <description>Stream with all the notifications of a module.</description>
          <replaySupport>false</replaySupport>
        </stream>
        <stream>
          <name>ietf-netconf-notifications</name>
          <description>Stream with all the notifications of a module.</description>
          <replaySupport>false</replaySupport>
        </stream>
        <stream>
          <name>nc-notifications</name>
          <description>Stream with all the notifications of a module.</description>
          <replaySupport>false</replaySupport>
        </stream>
        <stream>
          <name>ietf-keystore</name>
          <description>Stream with all the notifications of a module.</description>
          <replaySupport>false</replaySupport>
        </stream>
        <stream>
          <name>ietf-truststore</name>
          <description>Stream with all the notifications of a module.</description>
          <replaySupport>false</replaySupport>
        </stream>
        <stream>
          <name>ietf-network-instance</name>
          <description>Stream with all the notifications of a module.</description>
          <replaySupport>false</replaySupport>
        </stream>
        <stream>
          <name>ietf-subscribed-notifications</name>
          <description>Stream with all the notifications of a module.</description>
          <replaySupport>false</replaySupport>
        </stream>
        <stream>
          <name>ietf-yang-push</name>
          <description>Stream with all the notifications of a module.</description>
          <replaySupport>false</replaySupport>
        </stream>
        <stream>
          <name>ietf-hardware</name>
          <description>Stream with all the notifications of a module.</description>
          <replaySupport>false</replaySupport>
        </stream>
        <stream>
          <name>o-ran-supervision</name>
          <description>Stream with all the notifications of a module.</description>
          <replaySupport>false</replaySupport>
        </stream>
        <stream>
          <name>o-ran-file-management</name>
          <description>Stream with all the notifications of a module.</description>
          <replaySupport>false</replaySupport>
        </stream>
        <stream>
          <name>o-ran-trace</name>
          <description>Stream with all the notifications of a module.</description>
          <replaySupport>false</replaySupport>
        </stream>
        <stream>
          <name>o-ran-troubleshooting</name>
          <description>Stream with all the notifications of a module.</description>
          <replaySupport>false</replaySupport>
        </stream>
        <stream>
          <name>o-ran-software-management</name>
          <description>Stream with all the notifications of a module.</description>
          <replaySupport>false</replaySupport>
        </stream>
        <stream>
          <name>o-ran-uplane-conf</name>
          <description>Stream with all the notifications of a module.</description>
          <replaySupport>false</replaySupport>
        </stream>
        <stream>
          <name>o-ran-ald-port</name>
          <description>Stream with all the notifications of a module.</description>
          <replaySupport>false</replaySupport>
        </stream>
        <stream>
          <name>o-ran-antenna-calibration</name>
          <description>Stream with all the notifications of a module.</description>
          <replaySupport>false</replaySupport>
        </stream>
        <stream>
          <name>o-ran-externalio</name>
          <description>Stream with all the notifications of a module.</description>
          <replaySupport>false</replaySupport>
        </stream>
        <stream>
          <name>o-ran-performance-management</name>
          <description>Stream with all the notifications of a module.</description>
          <replaySupport>false</replaySupport>
        </stream>
        <stream>
          <name>o-ran-beamforming</name>
          <description>Stream with all the notifications of a module.</description>
          <replaySupport>false</replaySupport>
        </stream>
        <stream>
          <name>o-ran-aggregation-base</name>
          <description>Stream with all the notifications of a module.</description>
          <replaySupport>false</replaySupport>
        </stream>
      </streams>
    </netconf>
  </data>
</rpc-reply>
NETCONF rpc COMPLETE
Requesting 'CloseSession'
Sending:

#184
<nc:rpc xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:5b83f4d2-307a-46e8-a0e1-5998135f8052">
  <nc:close-session/>
</nc:rpc>

##
Received message from host
NETCONF DISCONNECT 172.19.3.183:830
No session found. Creating a new temporary session
Sending:
<nc:hello xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">...</nc:hello>
]]>]]>
Received message from host
initialized: session-id=53 | server_capabilities=<dict_keyiterator object at 0x7f5ef42ede50>
NETCONF CONNECTED 172.19.3.183:830
NETCONF SEND rpc
Requesting 'Dispatch'
Sending:

#297
<nc:rpc xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:59feae14-b68c-424a-b16a-8b293753671a"><create-subscription xmlns="urn:ietf:params:xml:ns:netconf:notification:1.0">
    <stream>NETCONF</stream>
  </create-subscription>
</nc:rpc>

##
Received message from host
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:59feae14-b68c-424a-b16a-8b293753671a">
  <ok/>
</rpc-reply>
NETCONF rpc COMPLETE
Requesting 'CloseSession'
Sending:

#184
<nc:rpc xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:5f0c5435-08dd-4d70-a164-79a1fb444865">
  <nc:close-session/>
</nc:rpc>

##
Received message from host
NETCONF DISCONNECT 172.19.3.183:830

Best regards, Thanks

miott commented 1 year ago

I thought XE only supported NETCONF RFC 5277 subscription. They later moved to using the ietf-event-notifications.yang module. Performing netconf subscriptions in yangsuite, in order to keep the session open, choose the device and "Open in new window" or "Open in new tab". In the device window you can manually "Start Session" and perform actions (including RFC 5277 streams). The session will stay open until you click on "End Session". Once the session is open, you can send subscribe messages using the ietf-event-notifications module from the NETCONF page.

rydy commented 1 year ago

The NETCONF configuration is as follows:

Device Variant : (Default - RFC-compliant device)
NETCONF port : 830
Address:172.19.3.183
Username:root
Password:••••••••
Timeout:30

I chose the device and click "Open Device Window", There is no "Start Session "button on this page. I tried to click "Open in new window", There is "Start Session" button on this new window. I manually clicked "Start Session" and run log as follows:

Waiting for Data...
Sending:
<nc:hello xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">...</nc:hello>
]]>]]>
Received message from host
initialized: session-id=9 | server_capabilities=<dict_keyiterator object at 0x7f59afff2ef0>
NETCONF CONNECTED 172.19.3.183:830
No session found. Creating a new temporary session
Sending:
<nc:hello xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">...</nc:hello>
]]>]]>
Received message from host
initialized: session-id=10 | server_capabilities=<dict_keyiterator object at 0x7f59b0077a40>
NETCONF CONNECTED 172.19.3.183:830
Ending temporary session
Requesting 'CloseSession'
Sending:

#184
<nc:rpc xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:232653ad-e99a-45e1-b6cb-0e4ca5e7f943">
  <nc:close-session/>
</nc:rpc>

##
Received message from host
NETCONF DISCONNECT 172.19.3.183:830
No session found. Creating a new temporary session
Sending:
<nc:hello xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">...</nc:hello>
]]>]]>
Received message from host
initialized: session-id=11 | server_capabilities=<dict_keyiterator object at 0x7f59b008d400>
NETCONF CONNECTED 172.19.3.183:830
Ending temporary session
Requesting 'CloseSession'
Sending:

#184
<nc:rpc xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:958eab9e-77bd-4d42-ab8f-026075219708">
  <nc:close-session/>
</nc:rpc>

##
Received message from host
NETCONF DISCONNECT 172.19.3.183:830
No session found. Creating a new temporary session
Sending:
<nc:hello xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">...</nc:hello>
]]>]]>
Received message from host
initialized: session-id=12 | server_capabilities=<dict_keyiterator object at 0x7f59b0098ea0>
NETCONF CONNECTED 172.19.3.183:830
Ending temporary session
Requesting 'CloseSession'
Sending:

#184
<nc:rpc xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:4dee16e8-cb19-4352-8789-20100648165e">
  <nc:close-session/>
</nc:rpc>

##
Received message from host
NETCONF DISCONNECT 172.19.3.183:830

I did not click "End Session" during this period, but "close-session" was still sent automatically. Why is this?

I then proceed to action "subscribe", which also automatically sends "close-session" without me clicking "End Session", Is there a problem with my operation?

No session found. Creating a new temporary session
Sending:
<nc:hello xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">...</nc:hello>
]]>]]>
Received message from host
initialized: session-id=13 | server_capabilities=<dict_keyiterator object at 0x7f59b007f040>
NETCONF CONNECTED 172.19.3.183:830
NETCONF SEND rpc
Requesting 'Dispatch'
Sending:

#297
<nc:rpc xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:9262a1c1-9d36-4be0-881a-426ae0fca18a"><create-subscription xmlns="urn:ietf:params:xml:ns:netconf:notification:1.0">
    <stream>NETCONF</stream>
  </create-subscription>
</nc:rpc>

##
Received message from host
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:9262a1c1-9d36-4be0-881a-426ae0fca18a">
  <ok/>
</rpc-reply>
NETCONF rpc COMPLETE
Requesting 'CloseSession'
Sending:

#184
<nc:rpc xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:99bded6d-33fc-4bc6-8506-f397dc4c81f3">
  <nc:close-session/>
</nc:rpc>

##
Received message from host
NETCONF DISCONNECT 172.19.3.183:830
miott commented 1 year ago

Cleaning up these old issues.

First, I see in your last comment that "Device Variant : (Default - RFC-compliant device)" and that setting is only for Nexus (IOS-NX) platforms and they do not support RFC-5277 type of streaming. Cisco IOS-XE and IOS_XR only support "NETCONF" streams for RFC-5277 type streaming. Second, the "Start Session" shows up in my new tab.

I tried my Cisco IOS-NX testbed and it returned no RFC-5277 streams as expected. My Cisco IOS-XE and IOS_XR testbeds only returned NETCONF as an RFC-5277 stream choice. All 3 devices do not close the session after I click on "Start Session".

What device are you trying this on? Does not appear to be a Cisco device.

Please re-open this issue if you need to.