我正在寻找一种将SMPP错误代码从服务器发送到连接的客户端的方法。 我的流程是: 1.客户端发送给我的服务器短信 2.我将其发送到另一个系统 3.当我收到消息状态时(最多可能需要72个小时) 我想将结果发送回作为接收方连接的客户端。 当我将其发送给客户端时,我也注意到了:
默认处理是丢弃意外响应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);
}
}
我正在寻找一种方法,以在发生错误时返回方法sendResponsePdu SMPP错误代码
我希望在客户端看到错误代码0xa 表示“无效的源地址” 但照常获得ESME_ROK 我从C#项目中提取图像,在其中可以看到响应的外观 从SMSC发送时
更新 我使用了下一个代码来返回DLR,但是我找不到设置“ err”,“ stat”和messageid的方法 enter link description here
答案 0 :(得分:0)
这是设置所有DLR字段并将其发送回客户端的解决方案
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) {
}