node-net-snmp icon indicating copy to clipboard operation
node-net-snmp copied to clipboard

RequestFailedError: EndOfMibView: for session.table() against Agent with MIB with a single table

Open sanielfishawy opened this issue 1 year ago • 4 comments

To reproduce:

Create an Agent with MIB containing a single table. Populate the table with rows.

Call session.table against that Agent with the OID of the table.

The final varbinds is an EndOfMibView as follows:

[
  {
    oid: '1.3.6.1.4.53387.0.5.6.112.115.73.100.95.49.801.15.98.97.116.116.101.114.121.95.118.111.108.116.97.103.101',
    type: 4,
    value: <Buffer 76 6f 6c 74 61 67 65 5f 76 61 6c 75 65 5f 30>
  }
]

[
  {
    oid: '1.3.6.1.4.53387.0.5.6.112.115.73.100.95.49.801.15.98.97.116.116.101.114.121.95.118.111.108.116.97.103.101',
    type: 130,
    value: null
  }
]

In the function tableFeedCb (index.js line 2425) this EndOfMibView is interpreted as an error and rather than returning the table the session.table() method returns a RequestFailedError: EndOfMibView:

RequestFailedError: EndOfMibView: 1.3.6.1.4.53387.0.5.6.112.115.73.100.95.49.801.15.98.97.116.116.101.114.121.95.118.111.108.116.97.103.101
      at Session.tableFeedCb (node_modules/net-snmp/index.js:2426:16)
      at Session.subtreeCb (node_modules/net-snmp/index.js:2306:11)
      at Session.walkCb (node_modules/net-snmp/index.js:2622:12)
      at Req.feedCb (node_modules/net-snmp/index.js:1986:8)
      at Session.onSimpleGetResponse [as onResponse] (node_modules/net-snmp/index.js:2179:7)
      at Session.onMsg (node_modules/net-snmp/index.js:2154:7)
      at Socket.emit (node:events:513:28)
      at UDP.onMessage [as onmessage] (node:dgram:933:8)

sanielfishawy avatar Jan 28 '24 06:01 sanielfishawy

Here are the lines of the tableFeedCb() method:

function tableFeedCb (req, varbinds) {
	for (var i = 0; i < varbinds.length; i++) {
		if (isVarbindError (varbinds[i])) {
			req.error = new RequestFailedError (varbindError (varbinds[i]));
			return true;
		}

sanielfishawy avatar Jan 28 '24 06:01 sanielfishawy

The culprit seems to be that isVarbindError interprets ObjectType.EndOfMibView as an error. This may be necessary in other circumstances but perhaps it is not correct in this case?

function isVarbindError (varbind) {
	return !!(varbind.type == ObjectType.NoSuchObject
	|| varbind.type == ObjectType.NoSuchInstance
	|| varbind.type == ObjectType.EndOfMibView);
}

sanielfishawy avatar Jan 28 '24 06:01 sanielfishawy

Hi @sanielfishawy - I followed your instructions but failed to reproduce the RequestFailedError. Can you please provide a minimal reproduction of this - with the exact code you use on the calling side and on the agent side. Thanks.

markabrahams avatar Jan 30 '24 00:01 markabrahams

I had the same issue. At the end of the snmpwalk there must be another OID. The table is then read without an error message.

hawk-666 avatar Jun 13 '24 11:06 hawk-666