使用 OpenSmpp 从 SMSC 接收消息

Receive message from SMSC using 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 为空时,但这是我的 pdu 调试:

(deliver: (pdu: 150 5 0 14) (addr: 1 1 22544803532) (addr: 2 1 98131) (sm: msg: id:256092548 sub:000 dlvrd:000 submit date:1708171009 done date:1708171009 stat:DELIVRD err:000 text:) (opt: ) )

有人可以帮我吗

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