exception of type 'System.Net.Sockets.SocketException' occurred in System.dll
Closed this issue · 5 comments
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 either by google or
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
Following is my code in which "Switches" is a type of List variable
that contains 10 "Switch" items. I am sure each switch's IP format is correct.
The exception does not occurs every time. But it often occurs, and, with
random IP in the "Switches List". I use" bigdipper_7.5_bin" on Win7 64bit
Enterprise (IPv4/IPv6) and VS2010 English version.
//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 codes calls "Socket" function too fast in a
"foreach" loop? Could you please give me some hints! Thanks again and a lot!
Original Reported Date: 2013-05-27T20:56:27.733-07:00
Original CodePlex Discussion Thread ID: 445154
Copied from CodePlex without authors:
Looking forward to hearing from you! thanks a lot!
Original Posted Date: 2013-05-30T18:05:10.793-07:00
Copied from CodePlex without authors:
As the exception message said, the 3 seconds (3000-ms) timeout was hit. You
might following this KB article to analyze the underlying data transfer on the
wire,
https://docs.lextudio.com/sharpsnmplib/tutorials/troubleshooting.html
Timeout is common, and you just need to change the default timeout value to a
bigger number in most cases.
Original Posted Date: 2013-05-30T19:17:18.497-07:00
Copied from CodePlex without authors:
Dear Lex,
I do not think the reason is timeout. Since there is a
System.Net.Sockets.SocketException occurred in System.dll before
TimeoutException.
Original Posted Date: 2013-05-31T01:59:09.377-07:00
Copied from CodePlex without authors:
The library is open source, so please read it and see how the SocketException
is caught and how the TimeoutException is generated.
Original Posted Date: 2013-05-31T06:49:46.157-07:00
Marked as Answer Date: 2013-10-06T20:17:33.937-07:00