Message processing model 3 returned error: Unsupported security level

Code works fine with AES128 but when I move to AES256 getting the below exceptions
org.snmp4j.MessageException: Message processing model 3 returned error: Unsupported security level
at org.snmp4j.MessageDispatcherImpl.sendPdu(MessageDispatcherImpl.java:524)
at org.snmp4j.Snmp.sendMessage(Snmp.java:1087)
at org.snmp4j.Snmp.send(Snmp.java:981)
at org.snmp4j.Snmp.send(Snmp.java:961)
at org.snmp4j.Snmp.send(Snmp.java:926)
at centina.sa.server.adapter.snmp.SnmpEntity.sendSyncCommunityPduFragment(SnmpEntity.java:2950)
at centina.sa.server.adapter.snmp.SnmpEntity.sendSyncV3PDU(SnmpEntity.java:2689)
at centina.sa.server.adapter.snmp.SnmpEntity.sendSyncV3PDU(SnmpEntity.java:2663)
at centina.sa.server.adapter.snmp.SnmpEntity.checkConnectionV3(SnmpEntity.java:1599)
at centina.sa.server.adapter.snmp.SnmpEntity.checkConnection(SnmpEntity.java:1397)
at centina.sa.server.adapter.snmp.SnmpEntity.connect(SnmpEntity.java:1737)
at centina.sa.server.adapter.snmp.SnmpAdapter.doConnect(SnmpAdapter.java:1289)
at centina.sa.server.adapter.Adapter.transition(Adapter.java:1109)
at centina.sa.server.adapter.Adapter.setConnectionState(Adapter.java:510)
at centina.sa.server.adapter.Adapter.connect(Adapter.java:1858)
at

Have you added the PrivAES256 privacy protocol to the SecurityProtocols instance used by Snmp?

Yes PrivAES256 is added as below
SecurityProtocols.getInstance().addPrivacyProtocol(new PrivAES256());

Problem is coming when we have the below code
MessageDispatcher msgDispatcher = new MessageDispatcherImpl();
Snmp snmp = new Snmp(msgDispatcher, transport);
snmp.getMessageDispatcher().addMessageProcessingModel( new MPv3() );

For the below code, it works fine
Snmp snmp = new Snmp(transport);

Could you please explain

Then maybe the authentication protocol is missing, that you want to use.
Try calling

        SecurityProtocols.getInstance().addDefaultProtocols();

before you send the message.

Below were already added
SecurityProtocols.getInstance().addDefaultProtocols();
SecurityProtocols.getInstance().addAuthenticationProtocol(new AuthHMAC128SHA224());
SecurityProtocols.getInstance().addAuthenticationProtocol(new AuthHMAC192SHA256());
SecurityProtocols.getInstance().addAuthenticationProtocol(new AuthHMAC256SHA384());
SecurityProtocols.getInstance().addAuthenticationProtocol(new AuthHMAC384SHA512());
SecurityProtocols.getInstance().addPrivacyProtocol(new Priv3DES());
SecurityProtocols.getInstance().addPrivacyProtocol(new PrivAES128());
SecurityProtocols.getInstance().addPrivacyProtocol(new PrivAES192());
SecurityProtocols.getInstance().addPrivacyProtocol(new PrivAES256());

Issue still exists

Hi,

then, maybe the user is not configured for authentication and privacy. Can you send a request with security level noAuthNoPriv?

Kind regards,
Jochen

Could be a misconfiguration of the local engine ID too, i.e. if you use the same engine ID for sender and receiver SNMPv3 entity. Without knowing the whole initialisation code, it is hard to guess where the error is. Have you checked the DEBUG log - maybe this gives a better understanding, what goes wrong?