Multithread SNMP4J over TLS

Hi all,
I am using SNMP4J V3.6.3 with openJdk 11.0.11 and I found something strange when i add a multi thread layer. With a single SNMP over TCP connection, I get no errors when I inspect each packet with wireshark. But when I start multi threading the connection (e.g. 5 thread sending a message), I sometimes found a strange TCP message with several SNMP body:

At first I suspected my application but when I place a critical section directly around the SNMP4J send method (protype of the method => ResponseEvent Snmp::send(PDU pdu,Target target) ), the problem no longer occurs at all.

Do i have to do something special to avoid this error ?


Why do you think that this is an error?
UDP ist packet oriented but TCP/TLS is not.

With your reaction in mind, i rechecked all the captured packet .

For me, the problem was that several packet with the same payload were in a single TCP Packet. I was not aware that SNMP over TCP can carry several SNMP message on one TCP packet and after counting each SNMP payload on each TCP packet it appears that there is no duplicate payload.

The problem comes from wireshark which misled me. When a packet like the one i show above is captured, the data is incorrectly shown in wireshark and each SNMP payload is related with the first SNMP payload ( i trusted wireshark on this point because the data packet is encrypted).

In conclusion, you are right, their is no issue at all and the fault is on me >_<. Thanks to correct me on this situation.


:+1: Yes, the fact that there is no message boundary is surprising and has some bad consequences too. When there is only a single bad encoded SNMP message, the whole connection has to be reset (i.e. closed and reopened on transport level).