问题描述
我已经实现了使用 Cloud Hopper 发送短信的功能。
public static SubmitSmResp sendShortMessage(String sourceAddress,byte[] textBytes,String destinationAddress) {
SubmitSmResp submitResponse = null;
try {
// set encoding for sending SMS
submit.setDataCoding(SmppConstants.DATA_CODING_JIS);
submit.setShortMessage(textBytes);
submit.setSourceAddress(new Address((byte) 0x05,(byte) 0x01,sourceAddress));
submit.setDestAddress(new Address((byte) 0x01,destinationAddress));
// submit message to SMSC for delivery with a timeout of 10000ms
submitResponse = session.submit(submit,10000);
if (submitResponse.getCommandStatus() == SmppConstants.STATUS_OK) {
System.out.println("SMS submitted,message id {}" + submitResponse.getMessageId());
} else {
throw new IllegalStateException(submitResponse.getResultMessage());
}
} catch (RecoverablePduException | UnrecoverablePduException | SmppTimeoutException |
SmppChannelException | InterruptedException e) {
throw new IllegalStateException(e);
} catch (Exception e) {
e.printStackTrace();
}
return submitResponse;
}
但是当我将我的 sim 卡插入 ios 设备时,我可以收到来自 smppgw 的消息。然后我将我的 sim 卡插入 android 设备,submitResponse.getCommandStatus() == SmppConstants.STATUS_OK 是 TRUE,但我无法接收我的短信。最后,我将我的 sim 卡插回我的 ios 设备,当我从 android 设备发送时收到消息。有谁知道如何解决这个问题?
解决方法
这听起来不像是 SMPP 客户端问题。我的意思是,只要您在发送 submit_sm 时收到状态为 OK 的 submit_sm_resp,就意味着该消息已被 SMSC/SMPPGW 接受。 听起来更像是 SMSC 问题或终端问题,因为问题在于从 SMSC 到终端的交付。
一个简单的解释可能是 Android 终端存在一些问题/信号丢失/未注册到网络,这就是 SMSC 不发送短信的原因。更换终端后,sim就在线,SMSC发送之前的短信