Reputation: 169
https://github.com/lextm/sharpsnmplib/blob/master/SharpSnmpLib/IP.cs
System.ArgumentException: bytes must contain 4 or 16 elements
at Lextm.SharpSnmpLib.IP..ctor(Tuple`2 length, Stream stream)
at Lextm.SharpSnmpLib.DataFactory.CreateSnmpData(Int32 type, Stream stream)
at Lextm.SharpSnmpLib.DataFactory.CreateSnmpData(Stream stream)
at Lextm.SharpSnmpLib.Sequence..ctor(Tuple`2 length, Stream stream)
at Lextm.SharpSnmpLib.DataFactory.CreateSnmpData(Int32 type, Stream stream)
at Lextm.SharpSnmpLib.DataFactory.CreateSnmpData(Stream stream)
at Lextm.SharpSnmpLib.Sequence..ctor(Tuple`2 length, Stream stream)
at Lextm.SharpSnmpLib.DataFactory.CreateSnmpData(Int32 type, Stream stream)
at Lextm.SharpSnmpLib.DataFactory.CreateSnmpData(Stream stream)
at Lextm.SharpSnmpLib.ResponsePdu..ctor(Tuple`2 length, Stream stream)
at Lextm.SharpSnmpLib.DataFactory.CreateSnmpData(Int32 type, Stream stream)
at Lextm.SharpSnmpLib.DataFactory.CreateSnmpData(Stream stream)
at Lextm.SharpSnmpLib.Sequence..ctor(Tuple`2 length, Stream stream)
at Lextm.SharpSnmpLib.DataFactory.CreateSnmpData(Int32 type, Stream stream)
at Lextm.SharpSnmpLib.Messaging.MessageFactory.ParseMessage(Int32 first, Stream stream, UserRegistry registry)
at Lextm.SharpSnmpLib.Messaging.MessageFactory.ParseMessages(Byte[] buffer, Int32 index, Int32 length, UserRegistry registry)
at Lextm.SharpSnmpLib.Messaging.SnmpMessageExtension.GetResponse(ISnmpMessage request, Int32 timeout, IPEndPoint receiver, UserRegistry registry, Socket udpSocket)
at Lextm.SharpSnmpLib.Messaging.SnmpMessageExtension.GetResponse(ISnmpMessage request, Int32 timeout, IPEndPoint receiver, Socket udpSocket)
at Lextm.SharpSnmpLib.Messaging.SnmpMessageExtension.GetResponse(ISnmpMessage request, Int32 timeout, IPEndPoint receiver)
at Lextm.SharpSnmpLib.Messaging.Messenger.BulkHasNext(VersionCode version, IPEndPoint endpoint, OctetString community, Variable seed, Int32 timeout, Int32 maxRepetitions, IList`1& next, IPrivacyProvider privacy, ISnmpMessage& report)
at Lextm.SharpSnmpLib.Messaging.Messenger.BulkWalk(VersionCode version, IPEndPoint endpoint, OctetString community, ObjectIdentifier table, IList`1 list, Int32 timeout, Int32 maxRepetitions, WalkMode mode, IPrivacyProvider privacy, ISnmpMessage report)
at Maprinter.snmpWalk..ctor(String IP, String ID, Int32 timeOut)
I'm using this library in order to pull some data from network printers. So far all works good and most of the printers return me the data I'm looking for. But when I get this error I don't receive anything from the printer so what's causes this error?
Messenger.BulkWalk(VersionCode.V2,
new IPEndPoint(IPAddress.Parse("10.0.0.101"), 161),
new OctetString("public"),
new ObjectIdentifier("1.3.6.1"),
result,
timeOut,
10,
WalkMode.Default,
null,
null);
Upvotes: 0
Views: 1179
Reputation: 63264
The exception was likely caused by the SNMP agent on that device who sent an empty IpAddress
body (0x40, 0x00). That violates the standard, as the result should be a Null
body (0x05, 0x00).
IpAddress
is defined in RFC2578, which is strictly of 4 bytes. That's why #SNMP checks against 4. The check against 16 is for IPv6 addresses, although they in fact should be supported by custom conventions.
In your case, the options can be,
Upvotes: 1