Discussion:
[SNMP4J] SNMP Buffer OverFlow Exception
vinod
2011-11-18 04:53:32 UTC
Permalink
Hi,

I am facing the Buffer OverFlow Exception when trying to do send a snmp
packet. The Stack Trace is given below.

java.nio.BufferOverflowException
at java.nio.Buffer.nextPutIndex(Buffer.java:513)
at java.nio.HeapByteBuffer.put(HeapByteBuffer.java:163)
at org.snmp4j.asn1.BEROutputStream.write(BEROutputStream.java:64)
at org.snmp4j.asn1.BER.encodeHeader(BER.java:119)
at org.snmp4j.smi.Null.encodeBER(Null.java:99)
at
org.snmp4j.smi.VariableBinding.encodeBER(VariableBinding.java:181)
at org.snmp4j.PDU.encodeBER(PDU.java:528)
at org.snmp4j.mp.MPv1.prepareOutgoingMessage(MPv1.java:132)
at
org.snmp4j.MessageDispatcherImpl.sendPdu(MessageDispatcherImpl.java:444)

I had increased all the memory limits in linux and still facing this
problem very often. Kindly guide me in solving the problem.

Thanks,
Vinod Kumar Boppanna
Frank Fock
2011-11-18 20:49:51 UTC
Permalink
Hi Vinod,

You do not have to change anything on OS level.
With SNMP you cannot send packets that exceed 64K.
But I do not think that this is the problem here.
I guess that you modify the PDU contents while it
is being encoded. Have you checked that already?

Best regards,
Frank
Post by vinod
Hi,
I am facing the Buffer OverFlow Exception when trying to do send a snmp
packet. The Stack Trace is given below.
java.nio.BufferOverflowException
at java.nio.Buffer.nextPutIndex(Buffer.java:513)
at java.nio.HeapByteBuffer.put(HeapByteBuffer.java:163)
at org.snmp4j.asn1.BEROutputStream.write(BEROutputStream.java:64)
at org.snmp4j.asn1.BER.encodeHeader(BER.java:119)
at org.snmp4j.smi.Null.encodeBER(Null.java:99)
at
org.snmp4j.smi.VariableBinding.encodeBER(VariableBinding.java:181)
at org.snmp4j.PDU.encodeBER(PDU.java:528)
at org.snmp4j.mp.MPv1.prepareOutgoingMessage(MPv1.java:132)
at
org.snmp4j.MessageDispatcherImpl.sendPdu(MessageDispatcherImpl.java:444)
I had increased all the memory limits in linux and still facing this
problem very often. Kindly guide me in solving the problem.
Thanks,
Vinod Kumar Boppanna
_______________________________________________
SNMP4J mailing list
SNMP4J at agentpp.org
http://lists.agentpp.org/mailman/listinfo/snmp4j
--
---
AGENT++
Maximilian-Kolbe-Str. 10
73257 Koengen, Germany
https://agentpp.com
Phone: +49 7024 8688230
Fax: +49 7024 8688231
vinod
2011-11-28 05:38:54 UTC
Permalink
Hi Frank,

Thanks for the reply. Sorry for very late reply.

Actually, i was not doing any modification while sending the SNMP Request.
After little inspection of the error it seems the snmp package was
trying to put a Byte data in the Buffer, but some how the data is larger
than a byte.
We got this error when we were using the snmp4j-1.11.1.jar package. I
had moved from this one to the very latest one snmp4j-2.0.2.jar package.

Till now, i have not faced the BufferOverflow Error. I guess the problem
is solved (any ways, i will test for few more days to be sure on this)

Thanks once again for the reply.

Regards,
Vinod Kumar Boppanna
Post by Frank Fock
Hi Vinod,
You do not have to change anything on OS level.
With SNMP you cannot send packets that exceed 64K.
But I do not think that this is the problem here.
I guess that you modify the PDU contents while it
is being encoded. Have you checked that already?
Best regards,
Frank
Post by vinod
Hi,
I am facing the Buffer OverFlow Exception when trying to do send a snmp
packet. The Stack Trace is given below.
java.nio.BufferOverflowException
at java.nio.Buffer.nextPutIndex(Buffer.java:513)
at java.nio.HeapByteBuffer.put(HeapByteBuffer.java:163)
at org.snmp4j.asn1.BEROutputStream.write(BEROutputStream.java:64)
at org.snmp4j.asn1.BER.encodeHeader(BER.java:119)
at org.snmp4j.smi.Null.encodeBER(Null.java:99)
at
org.snmp4j.smi.VariableBinding.encodeBER(VariableBinding.java:181)
at org.snmp4j.PDU.encodeBER(PDU.java:528)
at org.snmp4j.mp.MPv1.prepareOutgoingMessage(MPv1.java:132)
at
org.snmp4j.MessageDispatcherImpl.sendPdu(MessageDispatcherImpl.java:444)
I had increased all the memory limits in linux and still facing this
problem very often. Kindly guide me in solving the problem.
Thanks,
Vinod Kumar Boppanna
_______________________________________________
SNMP4J mailing list
SNMP4J at agentpp.org
http://lists.agentpp.org/mailman/listinfo/snmp4j
vinod
2011-12-15 11:57:23 UTC
Permalink
Hi,

I was trying to get MIB data from machines through SNMP using snmp4j
library. I am facing a problem where some times the machines are not
responding to the SNMP query (even with high time out and retries).
But if i wait for some time (lets say 3-5 minutes) and again query the
same machines (which earlier not responded), they are responding to the
SNMP queries. I was using various Operating systems and i had observed
that this type of problem is happening more in Windows 7 (may be its
just a coincidence). Does any body face this sort of problem?

Thanks,
Vinod Kumar Boppanna
Post by vinod
Hi Frank,
Thanks for the reply. Sorry for very late reply.
Actually, i was not doing any modification while sending the SNMP Request.
After little inspection of the error it seems the snmp package was
trying to put a Byte data in the Buffer, but some how the data is larger
than a byte.
We got this error when we were using the snmp4j-1.11.1.jar package. I
had moved from this one to the very latest one snmp4j-2.0.2.jar package.
Till now, i have not faced the BufferOverflow Error. I guess the problem
is solved (any ways, i will test for few more days to be sure on this)
Thanks once again for the reply.
Regards,
Vinod Kumar Boppanna
Post by Frank Fock
Hi Vinod,
You do not have to change anything on OS level.
With SNMP you cannot send packets that exceed 64K.
But I do not think that this is the problem here.
I guess that you modify the PDU contents while it
is being encoded. Have you checked that already?
Best regards,
Frank
Post by vinod
Hi,
I am facing the Buffer OverFlow Exception when trying to do send a snmp
packet. The Stack Trace is given below.
java.nio.BufferOverflowException
at java.nio.Buffer.nextPutIndex(Buffer.java:513)
at java.nio.HeapByteBuffer.put(HeapByteBuffer.java:163)
at org.snmp4j.asn1.BEROutputStream.write(BEROutputStream.java:64)
at org.snmp4j.asn1.BER.encodeHeader(BER.java:119)
at org.snmp4j.smi.Null.encodeBER(Null.java:99)
at
org.snmp4j.smi.VariableBinding.encodeBER(VariableBinding.java:181)
at org.snmp4j.PDU.encodeBER(PDU.java:528)
at org.snmp4j.mp.MPv1.prepareOutgoingMessage(MPv1.java:132)
at
org.snmp4j.MessageDispatcherImpl.sendPdu(MessageDispatcherImpl.java:444)
I had increased all the memory limits in linux and still facing this
problem very often. Kindly guide me in solving the problem.
Thanks,
Vinod Kumar Boppanna
_______________________________________________
SNMP4J mailing list
SNMP4J at agentpp.org
http://lists.agentpp.org/mailman/listinfo/snmp4j
_______________________________________________
SNMP4J mailing list
SNMP4J at agentpp.org
http://lists.agentpp.org/mailman/listinfo/snmp4j
Frank Fock
2013-04-30 22:25:55 UTC
Permalink
Hello Akshay,

I think the root cause is the buffer overflow exception.
First, you should fix that issue.

Possible causes are:
1. The PDU or any contained VariableBinding is modified by another
thread (for example the PDU sender) after calling asynchronous
Snmp.send*.
2. A variable binding is being sent, that is not supported by the
protocol version (as you send a scoped pdu, I think this cases is not
matching your case).

Then you can optimize the threading behavior by reducing the
bootle neck in Snmp.NotificationDispatcher.processPdu by
replacing it with:

public void processPdu(CommandResponderEvent event) {
CommandResponder listener;
synchronized (this) {
listener = notificationTransports.get(event.getTransportMapping());
}
if ((event.getPDU() != null) &&
(event.getPDU().getType() == PDU.INFORM)) {
// try to send INFORM response
try {
sendInformResponse(event);
}
catch (MessageException mex) {
if (logger.isWarnEnabled()) {
logger.warn("Failed to send response on INFORM PDU event (" +
event + "): " + mex.getMessage());
}
}
}
if (listener != null) {
listener.processPdu(event);
}
}

Best regards,
Frank
Hello Frank,
I am also facing below error in our application with SNMP4J stack (version is 1.11.1)
INFO | jvm 2 | 2013/04/29 13:36:54 | Exception in thread "Timer-7" java.nio.BufferOverflowException
INFO | jvm 2 | 2013/04/29 13:36:54 | at java.nio.Buffer.nextPutIndex(Unknown Source)
INFO | jvm 2 | 2013/04/29 13:36:54 | at java.nio.HeapByteBuffer.put(Unknown Source)
INFO | jvm 2 | 2013/04/29 13:36:54 | at org.snmp4j.asn1.BEROutputStream.write(BEROutputStream.java:64)
INFO | jvm 2 | 2013/04/29 13:36:54 | at org.snmp4j.asn1.BER.encodeHeader(BER.java:119)
INFO | jvm 2 | 2013/04/29 13:36:54 | at org.snmp4j.smi.VariableBinding.encodeBER(VariableBinding.java:178)
INFO | jvm 2 | 2013/04/29 13:36:54 | at org.snmp4j.PDU.encodeBER(PDU.java:528)
INFO | jvm 2 | 2013/04/29 13:36:54 | at org.snmp4j.ScopedPDU.encodeBER(ScopedPDU.java:123)
INFO | jvm 2 | 2013/04/29 13:36:54 | at org.snmp4j.mp.MPv3.prepareOutgoingMessage(MPv3.java:722)
INFO | jvm 2 | 2013/04/29 13:36:54 | at org.snmp4j.MessageDispatcherImpl.sendPdu(MessageDispatcherImpl.java:444)
INFO | jvm 2 | 2013/04/29 13:36:54 | at org.snmp4j.util.MultiThreadedMessageDispatcher.sendPdu(MultiThreadedMessageDispatcher.java:146)
INFO | jvm 2 | 2013/04/29 13:36:54 | at org.snmp4j.Snmp.sendMessage(Snmp.java:1067)
INFO | jvm 2 | 2013/04/29 13:36:54 | at org.snmp4j.Snmp$PendingRequest.run(Snmp.java:1610)
INFO | jvm 2 | 2013/04/29 13:36:54 | at java.util.TimerThread.mainLoop(Unknown Source)
INFO | jvm 2 | 2013/04/29 13:36:54 | at java.util.TimerThread.run(Unknown Source)
I took a thread dump and observed that all the dispatcher pool threads are in blocked state and hence SNMP4J stack is unable to process informs. So could you please let us know if it is known issue in SNMP4J stack version 1.11.1 ?
Thread dump from our apps
-------------------------------------------
"DispatcherPool.6" prio=3 tid=0x00a78c00 nid=0xe8 waiting for monitor entry [0x27e0f000]
java.lang.Thread.State: BLOCKED (on object monitor)
at org.snmp4j.Snmp$NotificationDispatcher.processPdu(Snmp.java:1825)
- waiting to lock <0x44c7c3d8> (a org.snmp4j.Snmp$NotificationDispatcher)
at org.snmp4j.Snmp.fireProcessPdu(Snmp.java:1430)
at org.snmp4j.Snmp.processPdu(Snmp.java:1288)
at org.snmp4j.MessageDispatcherImpl.fireProcessPdu(MessageDispatcherImpl.java:616)
at org.snmp4j.MessageDispatcherImpl.dispatchMessage(MessageDispatcherImpl.java:287)
at org.snmp4j.MessageDispatcherImpl.processMessage(MessageDispatcherImpl.java:347)
at org.snmp4j.util.MultiThreadedMessageDispatcher$MessageTask.run(MultiThreadedMessageDispatcher.java:209)
at org.snmp4j.util.ThreadPool$TaskManager.run(ThreadPool.java:239) - locked <
0x44cb3710> (a org.snmp4j.util.ThreadPool$TaskManager)
--
With Thanks & Regards,
Akshay Ballarpure
AOffice: +91-40-4472-4112
-----Original Message-----
From: snmp4j-bounces at agentpp.org [mailto:snmp4j-bounces at agentpp.org] On Behalf Of ext Frank Fock
Sent: Saturday, November 19, 2011 2:20 AM
To: snmp4j at agentpp.org
Subject: Re: [SNMP4J] SNMP Buffer OverFlow Exception
Hi Vinod,
You do not have to change anything on OS level.
With SNMP you cannot send packets that exceed 64K.
But I do not think that this is the problem here.
I guess that you modify the PDU contents while it
is being encoded. Have you checked that already?
Best regards,
Frank
Post by vinod
Hi,
I am facing the Buffer OverFlow Exception when trying to do send a snmp
packet. The Stack Trace is given below.
java.nio.BufferOverflowException
at java.nio.Buffer.nextPutIndex(Buffer.java:513)
at java.nio.HeapByteBuffer.put(HeapByteBuffer.java:163)
at org.snmp4j.asn1.BEROutputStream.write(BEROutputStream.java:64)
at org.snmp4j.asn1.BER.encodeHeader(BER.java:119)
at org.snmp4j.smi.Null.encodeBER(Null.java:99)
at
org.snmp4j.smi.VariableBinding.encodeBER(VariableBinding.java:181)
at org.snmp4j.PDU.encodeBER(PDU.java:528)
at org.snmp4j.mp.MPv1.prepareOutgoingMessage(MPv1.java:132)
at
org.snmp4j.MessageDispatcherImpl.sendPdu(MessageDispatcherImpl.java:444)
I had increased all the memory limits in linux and still facing this
problem very often. Kindly guide me in solving the problem.
Thanks,
Vinod Kumar Boppanna
_______________________________________________
SNMP4J mailing list
SNMP4J at agentpp.org
http://lists.agentpp.org/mailman/listinfo/snmp4j
--
---
AGENT++
Maximilian-Kolbe-Str. 10
73257 Koengen, Germany
https://agentpp.com
Phone: +49 7024 8688230
Fax: +49 7024 8688231
Frank Fock
2013-05-02 15:10:59 UTC
Permalink
Hi,

You probably misunderstood me. You do not need to synchronize anything,
just make sure that a PDU object is not modified after Snmp.send*
has been called. SNMP4J does not make an internal copy of the PDU
object for performance reasons. Thus, if you modify the object while
it is being send out, you get wrong results and BufferOverflowExceptions.

Best regards,
Frank
Thanks a lot Frank for information.
BTW, What is the fix here ?
Do I need to synchronize transport mapping only ?
Here is how I can create transport mapping.
private Snmp createSnmpSession (InetAddress address, int port)
throws IOException
{
s_logger.info ("Creating Snmp Session: " +
"addr = " + address + ", port = " + port);
TransportMapping transport = null;
if(address != null && port != -1)
{
transport = new DefaultUdpTransportMapping (
new UdpAddress (address, port));
}
else
{
transport = new DefaultUdpTransportMapping ();
}
// TODO - figure out how to use this properly - why are we
// doing this with only a pool size of one?
ThreadPool threadPool =
ThreadPool.create ("DispatcherPool", s_threadSize);
MessageDispatcher mtDispatcher = new MultiThreadedMessageDispatcher
(threadPool, new MessageDispatcherImpl ());
mtDispatcher.addMessageProcessingModel (new MPv1 ());
mtDispatcher.addMessageProcessingModel (new MPv2c ());
mtDispatcher.addMessageProcessingModel (s_mpv3);
Snmp snmp = new Snmp (mtDispatcher, transport);
return snmp;
}
--
With Thanks & Regards,
Akshay Ballarpure
AOffice: +91-40-4472-4112
-----Original Message-----
From: ext Frank Fock [mailto:fock at agentpp.com]
Sent: Wednesday, May 01, 2013 3:56 AM
To: Ballarpure, Akshay (NSN - IN/Hyderabad)
Cc: snmp4j at agentpp.org
Subject: Re: [SNMP4J] SNMP Buffer OverFlow Exception
Hello Akshay,
I think the root cause is the buffer overflow exception.
First, you should fix that issue.
1. The PDU or any contained VariableBinding is modified by another
thread (for example the PDU sender) after calling asynchronous
Snmp.send*.
2. A variable binding is being sent, that is not supported by the
protocol version (as you send a scoped pdu, I think this cases is not
matching your case).
Then you can optimize the threading behavior by reducing the
bootle neck in Snmp.NotificationDispatcher.processPdu by
public void processPdu(CommandResponderEvent event) {
CommandResponder listener;
synchronized (this) {
listener = notificationTransports.get(event.getTransportMapping());
}
if ((event.getPDU() != null) &&
(event.getPDU().getType() == PDU.INFORM)) {
// try to send INFORM response
try {
sendInformResponse(event);
}
catch (MessageException mex) {
if (logger.isWarnEnabled()) {
logger.warn("Failed to send response on INFORM PDU event (" +
event + "): " + mex.getMessage());
}
}
}
if (listener != null) {
listener.processPdu(event);
}
}
Best regards,
Frank
Hello Frank,
I am also facing below error in our application with SNMP4J stack (version is 1.11.1)
INFO | jvm 2 | 2013/04/29 13:36:54 | Exception in thread "Timer-7" java.nio.BufferOverflowException
INFO | jvm 2 | 2013/04/29 13:36:54 | at java.nio.Buffer.nextPutIndex(Unknown Source)
INFO | jvm 2 | 2013/04/29 13:36:54 | at java.nio.HeapByteBuffer.put(Unknown Source)
INFO | jvm 2 | 2013/04/29 13:36:54 | at org.snmp4j.asn1.BEROutputStream.write(BEROutputStream.java:64)
INFO | jvm 2 | 2013/04/29 13:36:54 | at org.snmp4j.asn1.BER.encodeHeader(BER.java:119)
INFO | jvm 2 | 2013/04/29 13:36:54 | at org.snmp4j.smi.VariableBinding.encodeBER(VariableBinding.java:178)
INFO | jvm 2 | 2013/04/29 13:36:54 | at org.snmp4j.PDU.encodeBER(PDU.java:528)
INFO | jvm 2 | 2013/04/29 13:36:54 | at org.snmp4j.ScopedPDU.encodeBER(ScopedPDU.java:123)
INFO | jvm 2 | 2013/04/29 13:36:54 | at org.snmp4j.mp.MPv3.prepareOutgoingMessage(MPv3.java:722)
INFO | jvm 2 | 2013/04/29 13:36:54 | at org.snmp4j.MessageDispatcherImpl.sendPdu(MessageDispatcherImpl.java:444)
INFO | jvm 2 | 2013/04/29 13:36:54 | at org.snmp4j.util.MultiThreadedMessageDispatcher.sendPdu(MultiThreadedMessageDispatcher.java:146)
INFO | jvm 2 | 2013/04/29 13:36:54 | at org.snmp4j.Snmp.sendMessage(Snmp.java:1067)
INFO | jvm 2 | 2013/04/29 13:36:54 | at org.snmp4j.Snmp$PendingRequest.run(Snmp.java:1610)
INFO | jvm 2 | 2013/04/29 13:36:54 | at java.util.TimerThread.mainLoop(Unknown Source)
INFO | jvm 2 | 2013/04/29 13:36:54 | at java.util.TimerThread.run(Unknown Source)
I took a thread dump and observed that all the dispatcher pool threads are in blocked state and hence SNMP4J stack is unable to process informs. So could you please let us know if it is known issue in SNMP4J stack version 1.11.1 ?
Thread dump from our apps
-------------------------------------------
"DispatcherPool.6" prio=3 tid=0x00a78c00 nid=0xe8 waiting for monitor entry [0x27e0f000]
java.lang.Thread.State: BLOCKED (on object monitor)
at org.snmp4j.Snmp$NotificationDispatcher.processPdu(Snmp.java:1825)
- waiting to lock <0x44c7c3d8> (a org.snmp4j.Snmp$NotificationDispatcher)
at org.snmp4j.Snmp.fireProcessPdu(Snmp.java:1430)
at org.snmp4j.Snmp.processPdu(Snmp.java:1288)
at org.snmp4j.MessageDispatcherImpl.fireProcessPdu(MessageDispatcherImpl.java:616)
at org.snmp4j.MessageDispatcherImpl.dispatchMessage(MessageDispatcherImpl.java:287)
at org.snmp4j.MessageDispatcherImpl.processMessage(MessageDispatcherImpl.java:347)
at org.snmp4j.util.MultiThreadedMessageDispatcher$MessageTask.run(MultiThreadedMessageDispatcher.java:209)
at org.snmp4j.util.ThreadPool$TaskManager.run(ThreadPool.java:239) - locked <
0x44cb3710> (a org.snmp4j.util.ThreadPool$TaskManager)
--
With Thanks & Regards,
Akshay Ballarpure
AOffice: +91-40-4472-4112
-----Original Message-----
From: snmp4j-bounces at agentpp.org [mailto:snmp4j-bounces at agentpp.org] On Behalf Of ext Frank Fock
Sent: Saturday, November 19, 2011 2:20 AM
To: snmp4j at agentpp.org
Subject: Re: [SNMP4J] SNMP Buffer OverFlow Exception
Hi Vinod,
You do not have to change anything on OS level.
With SNMP you cannot send packets that exceed 64K.
But I do not think that this is the problem here.
I guess that you modify the PDU contents while it
is being encoded. Have you checked that already?
Best regards,
Frank
Post by vinod
Hi,
I am facing the Buffer OverFlow Exception when trying to do send a snmp
packet. The Stack Trace is given below.
java.nio.BufferOverflowException
at java.nio.Buffer.nextPutIndex(Buffer.java:513)
at java.nio.HeapByteBuffer.put(HeapByteBuffer.java:163)
at org.snmp4j.asn1.BEROutputStream.write(BEROutputStream.java:64)
at org.snmp4j.asn1.BER.encodeHeader(BER.java:119)
at org.snmp4j.smi.Null.encodeBER(Null.java:99)
at
org.snmp4j.smi.VariableBinding.encodeBER(VariableBinding.java:181)
at org.snmp4j.PDU.encodeBER(PDU.java:528)
at org.snmp4j.mp.MPv1.prepareOutgoingMessage(MPv1.java:132)
at
org.snmp4j.MessageDispatcherImpl.sendPdu(MessageDispatcherImpl.java:444)
I had increased all the memory limits in linux and still facing this
problem very often. Kindly guide me in solving the problem.
Thanks,
Vinod Kumar Boppanna
_______________________________________________
SNMP4J mailing list
SNMP4J at agentpp.org
http://lists.agentpp.org/mailman/listinfo/snmp4j
--
---
AGENT++
Maximilian-Kolbe-Str. 10
73257 Koengen, Germany
https://agentpp.com
Phone: +49 7024 8688230
Fax: +49 7024 8688231
Frank Fock
2013-05-04 10:33:14 UTC
Permalink
Hi,

That question has to be solved by yourself.

Best regards,
Frank
Post by vinod
Hi Frank,
How to make sure PDU object is not being modified while sending?
--
With Thanks & Regards,
Akshay Ballarpure
AOffice: +91-40-4472-4112
-----Original Message-----
From: ext Frank Fock [mailto:fock at agentpp.com]
Sent: Thursday, May 02, 2013 8:41 PM
To: Ballarpure, Akshay (NSN - IN/Hyderabad)
Cc: snmp4j at agentpp.org
Subject: Re: [SNMP4J] SNMP Buffer OverFlow Exception
Hi,
You probably misunderstood me. You do not need to synchronize anything,
just make sure that a PDU object is not modified after Snmp.send*
has been called. SNMP4J does not make an internal copy of the PDU
object for performance reasons. Thus, if you modify the object while
it is being send out, you get wrong results and BufferOverflowExceptions.
Best regards,
Frank
Thanks a lot Frank for information.
BTW, What is the fix here ?
Do I need to synchronize transport mapping only ?
Here is how I can create transport mapping.
private Snmp createSnmpSession (InetAddress address, int port)
throws IOException
{
s_logger.info ("Creating Snmp Session: " +
"addr = " + address + ", port = " + port);
TransportMapping transport = null;
if(address != null && port != -1)
{
transport = new DefaultUdpTransportMapping (
new UdpAddress (address, port));
}
else
{
transport = new DefaultUdpTransportMapping ();
}
// TODO - figure out how to use this properly - why are we
// doing this with only a pool size of one?
ThreadPool threadPool =
ThreadPool.create ("DispatcherPool", s_threadSize);
MessageDispatcher mtDispatcher = new MultiThreadedMessageDispatcher
(threadPool, new MessageDispatcherImpl ());
mtDispatcher.addMessageProcessingModel (new MPv1 ());
mtDispatcher.addMessageProcessingModel (new MPv2c ());
mtDispatcher.addMessageProcessingModel (s_mpv3);
Snmp snmp = new Snmp (mtDispatcher, transport);
return snmp;
}
--
With Thanks & Regards,
Akshay Ballarpure
AOffice: +91-40-4472-4112
-----Original Message-----
From: ext Frank Fock [mailto:fock at agentpp.com]
Sent: Wednesday, May 01, 2013 3:56 AM
To: Ballarpure, Akshay (NSN - IN/Hyderabad)
Cc: snmp4j at agentpp.org
Subject: Re: [SNMP4J] SNMP Buffer OverFlow Exception
Hello Akshay,
I think the root cause is the buffer overflow exception.
First, you should fix that issue.
1. The PDU or any contained VariableBinding is modified by another
thread (for example the PDU sender) after calling asynchronous
Snmp.send*.
2. A variable binding is being sent, that is not supported by the
protocol version (as you send a scoped pdu, I think this cases is not
matching your case).
Then you can optimize the threading behavior by reducing the
bootle neck in Snmp.NotificationDispatcher.processPdu by
public void processPdu(CommandResponderEvent event) {
CommandResponder listener;
synchronized (this) {
listener = notificationTransports.get(event.getTransportMapping());
}
if ((event.getPDU() != null) &&
(event.getPDU().getType() == PDU.INFORM)) {
// try to send INFORM response
try {
sendInformResponse(event);
}
catch (MessageException mex) {
if (logger.isWarnEnabled()) {
logger.warn("Failed to send response on INFORM PDU event (" +
event + "): " + mex.getMessage());
}
}
}
if (listener != null) {
listener.processPdu(event);
}
}
Best regards,
Frank
Hello Frank,
I am also facing below error in our application with SNMP4J stack (version is 1.11.1)
INFO | jvm 2 | 2013/04/29 13:36:54 | Exception in thread "Timer-7" java.nio.BufferOverflowException
INFO | jvm 2 | 2013/04/29 13:36:54 | at java.nio.Buffer.nextPutIndex(Unknown Source)
INFO | jvm 2 | 2013/04/29 13:36:54 | at java.nio.HeapByteBuffer.put(Unknown Source)
INFO | jvm 2 | 2013/04/29 13:36:54 | at org.snmp4j.asn1.BEROutputStream.write(BEROutputStream.java:64)
INFO | jvm 2 | 2013/04/29 13:36:54 | at org.snmp4j.asn1.BER.encodeHeader(BER.java:119)
INFO | jvm 2 | 2013/04/29 13:36:54 | at org.snmp4j.smi.VariableBinding.encodeBER(VariableBinding.java:178)
INFO | jvm 2 | 2013/04/29 13:36:54 | at org.snmp4j.PDU.encodeBER(PDU.java:528)
INFO | jvm 2 | 2013/04/29 13:36:54 | at org.snmp4j.ScopedPDU.encodeBER(ScopedPDU.java:123)
INFO | jvm 2 | 2013/04/29 13:36:54 | at org.snmp4j.mp.MPv3.prepareOutgoingMessage(MPv3.java:722)
INFO | jvm 2 | 2013/04/29 13:36:54 | at org.snmp4j.MessageDispatcherImpl.sendPdu(MessageDispatcherImpl.java:444)
INFO | jvm 2 | 2013/04/29 13:36:54 | at org.snmp4j.util.MultiThreadedMessageDispatcher.sendPdu(MultiThreadedMessageDispatcher.java:146)
INFO | jvm 2 | 2013/04/29 13:36:54 | at org.snmp4j.Snmp.sendMessage(Snmp.java:1067)
INFO | jvm 2 | 2013/04/29 13:36:54 | at org.snmp4j.Snmp$PendingRequest.run(Snmp.java:1610)
INFO | jvm 2 | 2013/04/29 13:36:54 | at java.util.TimerThread.mainLoop(Unknown Source)
INFO | jvm 2 | 2013/04/29 13:36:54 | at java.util.TimerThread.run(Unknown Source)
I took a thread dump and observed that all the dispatcher pool threads are in blocked state and hence SNMP4J stack is unable to process informs. So could you please let us know if it is known issue in SNMP4J stack version 1.11.1 ?
Thread dump from our apps
-------------------------------------------
"DispatcherPool.6" prio=3 tid=0x00a78c00 nid=0xe8 waiting for monitor entry [0x27e0f000]
java.lang.Thread.State: BLOCKED (on object monitor)
at org.snmp4j.Snmp$NotificationDispatcher.processPdu(Snmp.java:1825)
- waiting to lock <0x44c7c3d8> (a org.snmp4j.Snmp$NotificationDispatcher)
at org.snmp4j.Snmp.fireProcessPdu(Snmp.java:1430)
at org.snmp4j.Snmp.processPdu(Snmp.java:1288)
at org.snmp4j.MessageDispatcherImpl.fireProcessPdu(MessageDispatcherImpl.java:616)
at org.snmp4j.MessageDispatcherImpl.dispatchMessage(MessageDispatcherImpl.java:287)
at org.snmp4j.MessageDispatcherImpl.processMessage(MessageDispatcherImpl.java:347)
at org.snmp4j.util.MultiThreadedMessageDispatcher$MessageTask.run(MultiThreadedMessageDispatcher.java:209)
at org.snmp4j.util.ThreadPool$TaskManager.run(ThreadPool.java:239) - locked <
0x44cb3710> (a org.snmp4j.util.ThreadPool$TaskManager)
--
With Thanks & Regards,
Akshay Ballarpure
AOffice: +91-40-4472-4112
-----Original Message-----
From: snmp4j-bounces at agentpp.org [mailto:snmp4j-bounces at agentpp.org] On Behalf Of ext Frank Fock
Sent: Saturday, November 19, 2011 2:20 AM
To: snmp4j at agentpp.org
Subject: Re: [SNMP4J] SNMP Buffer OverFlow Exception
Hi Vinod,
You do not have to change anything on OS level.
With SNMP you cannot send packets that exceed 64K.
But I do not think that this is the problem here.
I guess that you modify the PDU contents while it
is being encoded. Have you checked that already?
Best regards,
Frank
Post by vinod
Hi,
I am facing the Buffer OverFlow Exception when trying to do send a snmp
packet. The Stack Trace is given below.
java.nio.BufferOverflowException
at java.nio.Buffer.nextPutIndex(Buffer.java:513)
at java.nio.HeapByteBuffer.put(HeapByteBuffer.java:163)
at org.snmp4j.asn1.BEROutputStream.write(BEROutputStream.java:64)
at org.snmp4j.asn1.BER.encodeHeader(BER.java:119)
at org.snmp4j.smi.Null.encodeBER(Null.java:99)
at
org.snmp4j.smi.VariableBinding.encodeBER(VariableBinding.java:181)
at org.snmp4j.PDU.encodeBER(PDU.java:528)
at org.snmp4j.mp.MPv1.prepareOutgoingMessage(MPv1.java:132)
at
org.snmp4j.MessageDispatcherImpl.sendPdu(MessageDispatcherImpl.java:444)
I had increased all the memory limits in linux and still facing this
problem very often. Kindly guide me in solving the problem.
Thanks,
Vinod Kumar Boppanna
_______________________________________________
SNMP4J mailing list
SNMP4J at agentpp.org
http://lists.agentpp.org/mailman/listinfo/snmp4j
--
---
AGENT++
Maximilian-Kolbe-Str. 10
73257 Koengen, Germany
https://agentpp.com
Phone: +49 7024 8688230
Fax: +49 7024 8688231
Loading...