sharpsnmplib icon indicating copy to clipboard operation
sharpsnmplib copied to clipboard

Exception : System.Net.Sockets.SocketException

Open lextudio-support opened this issue 4 months ago • 4 comments

Hello,

I'm using SharpSNMP version 9.0.1 and I have the following exception throw by the library. Exception : System.Net.Sockets.SocketException :: A message sent on a datagram socket was larger than the internal message buffer or some other network limit, or the buffer used to receive a datagram into was smaller than the datagram itself

After some investigation, it appears that in my project, we receive large SNMP pdu, more than 8kb. In the interface we can only manage the max pdu size but by default it's near 64kb (Messenger.MaxMessageSize 65507 bytes). But at Socket level the value take into account is the defaut value from Socket.ReceiveBufferSize: Definition is as follow: // // Summary: // Gets or sets a value that specifies the size of the receive buffer of the // System.Net.Sockets.Socket. // // Returns: // An System.Int32 that contains the size, in bytes, of the receive buffer. // The default is 8192. // // Exceptions: // System.Net.Sockets.SocketException: // An error occurred when attempting to access the socket. // // System.ObjectDisposedException: // The System.Net.Sockets.Socket has been closed. // // System.ArgumentOutOfRangeException: // The value specified for a set operation is less than 0.

After managing to buil my own version of the library using Messenger.MaxMessageSize for the socket buffer allocation, the problem is fixed.

Regards, Rémi

Original Reported Date: 2016-06-22T04:43:20.513-07:00 Planned For Release: Original CodePlex ID: 7291

lextudio-support avatar Oct 21 '24 07:10 lextudio-support