Dear Lex,
First, thanks for your great work on SharpSNMP ! Yes, It's really a great work for windows network developers!
I encounter an exception problem and cannot fined answers by google and this forum. So my last resort is have to ask for you help.
The error messages are as following when I try to get, use BulkWalk method, all "dot1qTpFdbPort(1.3.6.1.2.1.17.7.1.2.2.1.2)" information from a switch:
First, thanks for your great work on SharpSNMP ! Yes, It's really a great work for windows network developers!
I encounter an exception problem and cannot fined answers by google and this forum. So my last resort is have to ask for you help.
The error messages are as following when I try to get, use BulkWalk method, all "dot1qTpFdbPort(1.3.6.1.2.1.17.7.1.2.2.1.2)" information from a switch:
A first chance exception of type 'System.Net.Sockets.SocketException' occurred in System.dll
A first chance exception of type 'Lextm.SharpSnmpLib.Messaging.TimeoutException' occurred in SharpSnmpLib.dll
SNMPException:TimeoutException: timeout: 3000
I use" bigdipper_7.5_bin" on Win7 64bit Enterprise (IPv4/IPv6) and VS2010 English version. The exception messages does not occurs every time. But it often occurs, and, with different IP. Following is my code in which "Switches" is a type of List<Switch> variable that contains 10 "Switch" items. //get all switch's MAC-PortIndex table
foreach (Switch SW in Switches)
{
ObjectIdentifier OID = new ObjectIdentifier("1.3.6.1.2.1.17.7.1.2.2.1.2"); //dot1qTpFdbPort
try
{
var result = new List<Variable>();
Messenger.BulkWalk(VersionCode.V2,
new IPEndPoint(IPAddress.Parse(SW.EntIPAddr), 161),
new OctetString(tbCommunity.Text),
OID, result, 3000, 10,
WalkMode.WithinSubtree,
null, null);
foreach (Variable variable in result)
{
... ...
}
}
catch (SnmpException ex)
{
Console.WriteLine("SNMPException:" + ex);
}
catch (SocketException ex)
{
Console.WriteLine("SocketException:" + ex);
}
catch (Exception ex)
{
Console.WriteLine("!!!Exception:" + SW.EntIPAddr.ToString() + " " + ex.ToString());
}
Is it correlated with IPv6 or the program calls "Socket" function too fast in a "foreach" loop? Do you ever encountered this situation before ? Could you please give me some hints! Thanks again and a lot!