Author | Forum: PowerSNMP for .NET Topic: Dart.Snmp.Agent.Send method throwoing exception with NotificationMessage |
bhaviksuthar From: london, United Kingdom Posts: 3 Member Since: 12/02/09 |
posted January 27, 2010 10:18 AM Hi, I am trying to send a notification using the code block below. MibNode node = m_agent.Mib.GetByNodeName(nodeName); NotificationMessage notification = new NotificationMessage(node.Oid, node.Description); ariable var = new Variable(node, "1"); notification.Variables.Add(var); m_agent.Send(notification, destIpAddress); The code throws an exception when it hits Send method saying "Index was out of range. Must be non-negative and less than the size of the collection.\r\nParameter name: index" with the stacktrace at System.Collections.ArrayList.get_Item(Int32 index) at Dart.Snmp.Sequence.0(Int32 ) at Dart.Snmp.Variable.0(MemoryStream ) at Dart.Snmp.Sequence.0(MemoryStream ) at Dart.Snmp.Sequence.0(MemoryStream ) at Dart.Snmp.Sequence.0(MemoryStream ) at Dart.Snmp.TaggedType.Encode() at Dart.Snmp.MessageBase.Encode() at Dart.Snmp.StandardMessage.Encode() at Dart.Snmp.NotificationMessage.Encode() at Dart.Snmp.SnmpBase.Send(MessageBase message, IPEndPoint remoteEndPoint) at Dart.Snmp.Agent.Send(MessageBase message, String hostNameOrAddress) Can you please clarify why I can't add the variable this way? I tried a different approach with following code block MibNode node = m_agent.Mib.GetByNodeName(nodeName); NotificationMessage notification = new NotificationMessage(node.Oid, node.Description); Variable var = new Variable(node.Oid, new Dart.Snmp.SimpleType.Integer("1")); notification.Variables.Add(var); m_agent.Se |
Mike Baldwin (Admin)![]() From: Rome, NY USA Posts: 114 Member Since: 04/11/00 Extra Support Options Custom Application Development |
posted January 27, 2010 11:48 AM Hi, The key to this seems to be your use of nodeName. What value are you using? It may be that this MibNode does not have a ValueType defined (so it doesn't know what to do with the "1" string.) In your second example, you've side-stepped this failure by specifying the type as an Integer, so the library can properly encode the NotificationMessage. In your last message you state the receiving Manager "loses" the variable definition. This is because the Manager can't correlate the Oid your sending with an entry in the Mib it is using. You need to check that part of your system. We'll help protect you (and others) from inadvertently creating a Variable with a node that doesn't have good ValueType information in it. I've entered a feature request to throw an immediate exception when this occurs. On a personal note, it's great having our friends across the pond using our products. We appreciate it! |
bhaviksuthar From: london, United Kingdom Posts: 3 Member Since: 12/02/09 |
posted January 27, 2010 12:39 PM Thanks Mike. I still have a concern about loosing the Definition value on the manager side. I am using your Trap Catcher sample and when in TrapLogEntry.cs, I iterate through the NotificationMessage.Variables list, I get the variable values but the Definition of that variable is always null. This time I am setting the notificationMessage from agent as Variable var = new Variable(node); var.Value = new Dart.Snmp.SimpleType.Integer(notificationValue); So believe it should contain the definition at manager side as well??? |
Mike Baldwin (Admin)![]() From: Rome, NY USA Posts: 114 Member Since: 04/11/00 Extra Support Options Custom Application Development |
posted January 28, 2010 2:26 PM If you send me the value of nodeName you are using I can look into this a little further. |
Reply | PowerSNMP for .NET Topics | Forums |
This site is powered by
![]() |