Problems decoding multiple PDUs in datagram; decoded as may as possible
scottrbrtsn opened this issue · 4 comments
Any idea why I'm getting this in the console (infinitely) as a result of a generic exception: "Problems decoding multiple PDUs in datagram; decoded as may as possible"
From line 428 in PduFactory.java (getPdusFromBundle)
The implementation I was using (was working until a few days ago, I think something got pushed from our DIS folks)
public List<Pdu> getCurrentBundle() {
List<Pdu> toReturn = new ArrayList<>();
LOGGER.debug("getBundle");
try {
toReturn = getListFromBuffer();
} // End try
catch (Exception e) {
LOGGER.error(e);
}
return toReturn;
}
private List<Pdu> getListFromBuffer(){
DatagramPacket packet;
PduFactory pduFactory = new PduFactory();
byte buffer[] = new byte[MAX_PDU_SIZE];
packet = new DatagramPacket(buffer, buffer.length);
try {
socket.receive(packet);
}catch (Exception e){
LOGGER.error(e);
}
List<Pdu> pduBundle = pduFactory.getPdusFromBundle(packet.getData());
return pduBundle;
}
I'm guessing PduFactory.createPdu
is throwing that exception. It's hard to know exactly why without your data, but could one of the Pdu's be malformed?
That error message your're seeing repeated...I think what should be happening is the catch
in PduFacotry.getPdusFromBundle
should be calling break
. Otherwise the value of pduStartPointInData
won't change and on the next loop it will call createPdu
with the same byte buffer. That part is an easy improvement, I'll fix that.
This was triggered by a pdu made during development, and was also structured to be a DataPdu but with pduType set to be a SetDataPdu, and was structured incorrectly.
I copied the function and added a break
. This proved to fix the problem as it no longer continued in the infinite loop.
Ok good to hear.
Btw if you pull the latest build from jitpack it will have this fix in it now.