Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNMP Exception : data construction exception #186

Open
antoheb opened this issue Jul 20, 2023 · 0 comments
Open

SNMP Exception : data construction exception #186

antoheb opened this issue Jul 20, 2023 · 0 comments

Comments

@antoheb
Copy link

antoheb commented Jul 20, 2023

Here is my function in the code below and also the exception message. I basically want to do a walk operation on a snmp device. My problem is when I call this function on a OID with only one value, the walk operation returns me the value I want. But when I tried to call my function on a OID table, this exception is always thrown. It looks like the walk operation cannot build my list of variable when mutliple variable exists.

************* My Function *****************
private void walk_snmp(VersionCode snmpVersion, String ipAddress, Int32 port, String communityString, String OID)
{
var results = new List();
Messenger.BulkWalk(snmpVersion,
new IPEndPoint(IPAddress.Parse(ipAddress), port),
new OctetString(communityString),
null,
new ObjectIdentifier(OID),
results,
20000,
10,
WalkMode.WithinSubtree,
null,
null);

foreach (Variable result in results)
{
    this.operationInfoBox.Text = "OID : " + result.Id.ToString() + " Result = " + result.Data.ToString() + "\n";
}

}

************** Exception Text **************
Lextm.SharpSnmpLib.SnmpException: data construction exception ---> System.ArgumentException: Invalid varbind data length: 1.
Parameter name: varbindSection
at Lextm.SharpSnmpLib.Variable.Transform(Sequence varbindSection)
at Lextm.SharpSnmpLib.ResponsePdu..ctor(Tuple2 length, Stream stream) at Lextm.SharpSnmpLib.DataFactory.CreateSnmpData(Int32 type, Stream stream) --- End of inner exception stack trace --- at Lextm.SharpSnmpLib.DataFactory.CreateSnmpData(Int32 type, Stream stream) at Lextm.SharpSnmpLib.DataFactory.CreateSnmpData(Stream stream) at Lextm.SharpSnmpLib.Sequence..ctor(Tuple2 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 receiver, OctetString community, OctetString contextName, Variable seed, Int32 timeout, Int32 maxRepetitions, IList1& next, IPrivacyProvider privacy, ISnmpMessage& report) at Lextm.SharpSnmpLib.Messaging.Messenger.BulkWalk(VersionCode version, IPEndPoint endpoint, OctetString community, OctetString contextName, ObjectIdentifier table, IList1 list, Int32 timeout, Int32 maxRepetitions, WalkMode mode, IPrivacyProvider privacy, ISnmpMessage report)
at snmp_agent.Form1.walk_snmp(VersionCode snmpVersion, String ipAddress, Int32 port, String communityString, String OID)
at snmp_agent.Form1.submitBtn_click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants