node-net-snmp
node-net-snmp copied to clipboard
RequestFailedError: EndOfMibView: for session.table() against Agent with MIB with a single table
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)
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;
}
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);
}
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.
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.