opentelecoms-org / jsmpp

SMPP implemented in Java
Apache License 2.0
232 stars 163 forks source link

Send DLR in SMPPServerSimulator #56

Open EdiMel opened 8 years ago

EdiMel commented 8 years ago

Hi all

I'm trying to create a SMPP server, using the SMPPServerSimulator example as a start point. I'm using kannel to emulate a real SMPP client. Kannel successfully binds, send submit_sm, receive submit_sm_resp but rejects deliver_sm:

got DLR but could not find message or was not interested in it id<870928761> dst<123>, type<1>

If I change the code in DeliveryReceiptTask from:

DeliveryReceipt delRec = new DeliveryReceipt(stringValue, totalSubmitted, totalDelivered, new Date(), new Date(), DeliveryReceiptState.DELIVRD, "000", new String(shortMessage));

to

DeliveryReceipt delRec = new DeliveryReceipt(messageId.getValue(), totalSubmitted, totalDelivered, new Date(), new Date(), DeliveryReceiptState.DELIVRD, "000", new String(shortMessage));

Kannel process the deliver_sm correctly. Can you tell me pls what is wrong ?

pmoerenhout commented 8 years ago

The id in the DeliveryReceipt is the messageId for which the delivery receipt is generated. It normally is a 10-digit string, prefixed with 0 digits, but the SMPP spec doesn not obligate a particular format. So when the DLR with id 870928761 is received, is comes from a message id 33E95179 because it's using the RandomMessageIDGenerator which generates like new MessageId(Integer.toString(random.nextInt(Integer.MAX_VALUE), 16)); The DeliveryReceiptTask puts in into the 10 digit format, but Kannel doesn't expect this. So the conversion you did is OK. It all depends what kind of message id you use, and how to format them in de DLR. The most 'compliant' way is to use a MessageIdGenerator which always produces 10-digits strings. I added the RandomDecimalMessageIDGenerator in the jSMPP package for that. You can use that in the SMPPServer.