Reputation: 395
i am looking for a way to send SMPP error codes from the server to the connected client. my Flow is : 1. client send to my Server text message 2. i send it to another system 3. when i got status of messages (can take up to 72 hours) i want to send the results back to the client that is connected as a Receiver. also i noticed when i send it to the client i see :
Default handling is to discard unexpected response PDU: (submit_sm_resp:
public void sendResponsePdu(String dlrId, String status) throws RecoverablePduException, SmppChannelException, UnrecoverablePduException, InterruptedException {
PduResponse pdu = dlrs.remove(dlrId);
if (pdu != null) {
pdu.setResultMessage("0xa");
sendResponsePdu(pdu);
}
}
i look for a way to return on method sendResponsePdu the SMPP error code in case of an error
i expect to see in client the error code 0xa
which means "Invalid source address"
but get as usual ESME_ROK
i toke image from C# project where i can see how the response should look like
when send from SMSC
UPDATE i used the next code to return the DLR, but i can't find a way to set the "err","stat" and messageid enter link description here
Upvotes: 0
Views: 872
Reputation: 395
this is the solution to set all DLR fields and send it back to the client
byte[] textBytes = "-".getBytes();
DeliverSm deliver = new DeliverSm();
deliver.setSourceAddress(new Address((byte) 0x03, (byte) 0x00, pduResponseWrapper.getFromNumber()));
deliver.setDestAddress(new Address((byte) 0x01, (byte) 0x01, pduResponseWrapper.getToNumber()));
deliver.setShortMessage(textBytes);
deliver.setDataCoding(pduResponseWrapper.getDataCoding());
deliver.setSequenceNumber(pduResponseWrapper.getDeliverSm().getSequenceNumber());
deliver.setEsmClass((byte) 0x04);
deliver.setProtocolId((byte) 0x00);
deliver.setPriority((byte) 0x00);
deliver.setScheduleDeliveryTime(null);
deliver.setValidityPeriod(null);
deliver.setRegisteredDelivery((byte) 0x00);
deliver.setReplaceIfPresent((byte) 0x00);
deliver.setDefaultMsgId((byte) 0x00);
DateTime submitDate = new DateTime();
DateTime doneDate = new DateTime();
byte state=SmppConstants.STATE_DELIVERED;
String errorCode="000";
DeliveryReceipt deliveryReceipt = new DeliveryReceipt(dlrId, 1,
1, submitDate, doneDate,
state, errorCode, "");
String shortMessage = deliveryReceipt.toShortMessage();
deliver.setShortMessage(CharsetUtil.encode(shortMessage, CharsetUtil.CHARSET_GSM)); deliver.calculateAndSetCommandLength();
DataSmResp dd=new DataSmResp();
DeliveryReceipt deliveryReceipt=new DeliveryReceipt();
DeliverSmResp deliverSmResp = new DeliverSmResp();*/
WindowFuture<Integer, PduRequest, PduResponse> future = session.sendRequestPdu(deliver, 10000, false);
if (!future.await()) {
logger.error("Failed to receive deliver_sm_resp within specified time");
} else if (future.isSuccess()) {
DeliverSmResp deliverSmResp = (DeliverSmResp) future.getResponse();
logger.info("deliver_sm_resp: commandStatus [" + deliverSmResp.getCommandStatus() + "=" + deliverSmResp.getResultMessage() + "]");
} else {
logger.error("Failed to properly receive deliver_sm_resp: " + future.getCause());
}
} catch (Exception e) {
}
Upvotes: 0