2

i'm trying to receive messages from SMSC using the OPENSMPP. this is my code:

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 );
}

that's code working normaly when i connected to SMSC but when i change the SMSC to an other center SMSC i got this error:

SMPP.org.pdu.ValueNotSetException

when i trace that i got that the message id is null but this is my pdu debug:

(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: ) )

can someone help me please.

Mhammad Sellam
  • 160
  • 1
  • 15

1 Answers1

2

The pdu debug String indicates that the message id and every other parameters is sent by the SMSC. Make sure that you are tracing the correct pdu .

karthi keyan
  • 213
  • 2
  • 19
  • yes it is the correct pdu. me too i remarque that the message id is in the pdu by still not working. i have the error from the method when i call to : received.getReceiptedMessageId() – Mhammad Sellam Aug 17 '17 at 14:30
  • Actually,that is not the right method to get the value of the message id from the DeliverySM. RecieptedMessageId is an optional parameter in DeliverSM pdu. It is best practise by using the function hasReceiptedMessageId() and try to get the value of it.Now,in your case try to get the id value by using functions like split() and substring(). – karthi keyan Aug 17 '17 at 14:37
  • i will try that and i will post the response here if it working – Mhammad Sellam Aug 17 '17 at 14:57
  • Thanks karthi keyan it working i add 2 methode, one to get the message id from debug string and an other to get the message status. it's working now :D – Mhammad Sellam Aug 17 '17 at 17:55