使用OpenSmpp从SMSC接收消息

时间:2017-08-17 10:31:15

标签: java opensmpp

我尝试使用OPENSMPP从SMSC接收消息。 这是我的代码:

try{
    PDU pdu = session.receive(30000);
    if(pdu instanceof DeliverSM){
        DeliverSM received = (DeliverSM) pdu;
        if (received.getEsmClass() == 0) {                                                          // new message
            logger.debug("RECEIVE NEW MESSAGE:" + received.debugString());
            String MSG_SENDER = received.getSourceAddr().getAddress();
            String SHORT_MSG = received.getShortMessage();
        } else {                                                                                    // delivry Repport
            logger.debug("RECEIVE NEW DELIVERED REPORT:" + received.debugString());
            String MSG_ID = (new BigInteger(received.getReceiptedMessageId(), 16)) + "";
            int MSG_STATUS = received.getMessageState();
        }
    }else{
        logger.debug("----------------- FF pdu: " +pdu.debugString());
    }
} catch (TimeoutException e) {
    logger.error("------------------------- ["+SMSC_NAME+"] SMPP RECEIVED TimeoutException "+e.getMessage()+" ---------------- ", e );
} catch (ValueNotSetException e){
    logger.error("-------------------------["+SMSC_NAME+"]  SMPP RECEIVED ValueNotSetException "+e.getMessage()+" ---------------- ", e );
} catch (WrongLengthOfStringException e) {
    logger.error("-------------------------["+SMSC_NAME+"]  SMPP RECEIVED WrongLengthOfStringException "+e.getMessage()+" ---------------- ", e );
} catch (PDUException e) {
    logger.error("-------------------------["+SMSC_NAME+"]  SMPP RECEIVED PDUException "+e.getMessage()+" ---------------- ", e );
} catch (IOException e) {
    logger.error("-------------------------["+SMSC_NAME+"]  SMPP RECEIVED IOException "+e.getMessage()+" ---------------- ", e );
}catch (NotSynchronousException e) {
    logger.error("-------------------------["+SMSC_NAME+"]  SMPP RECEIVED NotSynchronousException "+e.getMessage()+" ---------------- ", e );
}catch (Exception e) {
    logger.error("-------------------------["+SMSC_NAME+"]  SMPP RECEIVED Exception "+e.getMessage()+" ---------------- ", e );
}
当我连接到SMSC但当我将SMSC更改为其他中心SMSC时,该代码正常工作我得到了这个错误:

  

SMPP.org.pdu.ValueNotSetException

当我跟踪我得到的消息id为null但这是我的pdu调试:

  

(交付:( pdu:150 5 0 14)(地址:1 1 22544803532)(地址:2 1 98131)   (sm:msg:id:256092548 sub:000 dlvrd:000提交日期:1708171009完成   日期:1708171009 stat:DELIVRD错误:000文:):(opt :))

请有人帮助我。

1 个答案:

答案 0 :(得分:2)

pdu debug String表示SMSC发送消息id和所有其他参数。确保您正在追踪正确的pdu。

相关问题