I'm having a problem processing MO requests from a specific SMSC connection using jsmpp.
The connection in question is properly bound and works perfectly for MT requests; however, when we get the callback that an MO is received, the short_message property of the PDU reads as blank. Here is a print out of what I see in the logs:
02:05:47,255 DEBUG [SmppConnectionManagerImpl] onAcceptDeliverSm: From: 9178386944 To: 2184 ESM: 0 Msg:
02:05:47,255 DEBUG [SmppConnectionManagerImpl] BYTE ARRAY LENGTH
02:05:47,256 DEBUG [SmppConnectionManagerImpl] 0
02:05:47,256 DEBUG [SmppConnectionManagerImpl] COMMAND STATUS
02:05:47,256 DEBUG [SmppConnectionManagerImpl] 0
02:05:47,256 DEBUG [SmppConnectionManagerImpl] DATA CODING
02:05:47,256 DEBUG [SmppConnectionManagerImpl] 0
02:05:47,256 DEBUG [SmppConnectionManagerImpl] COMMAND LENGTH
02:05:47,256 DEBUG [SmppConnectionManagerImpl] 114
02:05:47,256 DEBUG [SmppConnectionManagerImpl] -
02:05:47,256 DEBUG [SmppConnectionManagerImpl]
02:05:47,256 DEBUG [SmppConnectionManagerImpl] -
02:05:47,256 DEBUG [SmppConnectionManagerImpl]
02:05:47,256 DEBUG [SmppConnectionManagerImpl] -
02:05:47,256 DEBUG [SmppConnectionManagerImpl]
02:05:47,256 DEBUG [SmppConnectionManagerImpl] -
02:05:47,256 DEBUG [SmppConnectionManagerImpl]
02:05:47,256 DEBUG [SmppConnectionManagerImpl] -
02:05:47,256 DEBUG [SmppConnectionManagerImpl]
02:05:47,256 DEBUG [SmppConnectionManagerImpl] ========
And the code that produced it:
LOG.debug("onAcceptDeliverSm: From: {} To: {} ESM: {} Msg: {}", deliverSm.getSourceAddr(),
deliverSm.getDestAddress(), deliverSm.getEsmClass(), new String(deliverSm.getShortMessage()));
LOG.debug("BYTE ARRAY LENGTH");
LOG.debug(Integer.toString(deliverSm.getShortMessage().length));
LOG.debug("COMMAND STATUS");
LOG.debug(Integer.toString(deliverSm.getCommandStatus()));
LOG.debug("DATA CODING");
LOG.debug(Integer.toString(new Byte(deliverSm.getDataCoding()).intValue()));
LOG.debug("COMMAND LENGTH");
LOG.debug(Integer.toString(deliverSm.getCommandLength()));
LOG.debug("-");
LOG.debug(new String(deliverSm.getShortMessage(), Charset.forName("US-ASCII")));
LOG.debug("-");
LOG.debug(new String(deliverSm.getShortMessage(), Charset.forName("ISO-8859-1")));
LOG.debug("-");
LOG.debug(new String(deliverSm.getShortMessage(), Charset.forName("UTF-16BE")));
LOG.debug("-");
LOG.debug(new String(deliverSm.getShortMessage(), Charset.forName("UTF-16LE")));
LOG.debug("-");
LOG.debug(new String(deliverSm.getShortMessage(), Charset.forName("UTF-16")));
As you can see, we are getting data from the SMSC; however, when we try to read out the short message, it returns an empty byte array. Other fields (like the source and dest address) are returning okay.
Additionally, when we have people send variable length MOs, the command length is variable - indicating that the data is there somehow, it's just not able to be read for some reason.
Would appreciate any leads on things that could cause the short message byte array to come back as blank and configuration settings to try to fix the problem.
This ended up being an issue with the way the SMSC in question packaged it's responses. In their case, rather than sending the message data in short_message part of the PDU, the message data was being sent in the optional message_payload part of the PDU.
Here is the code we ended up with to parse out the message
private String getMessageBody(DeliverSm deliverSm) {
byte[] bytes = Optional.ofNullable(deliverSm.getOptionalParameter(OptionalParameter.Message_payload.class))
.map(x -> x.getValue())
.filter(x -> x != null && x.length > 0)
.orElse(deliverSm.getShortMessage());
return Optional.ofNullable(bytes)
.filter(x -> x != null && x.length > 0)
.map(x -> new String(x, UTF8))
.orElse("");
}