Can't send multipart sms message over SMPP in java
Asked Answered
T

1

7

I am trying to send a multipart sms message in java.

    public static void main(String[] args) throws Exception {
    SMPPSession session = new SMPPSession();
    session.connectAndBind("0.0.0.0", 00000, new BindParameter(
                BindType.BIND_TX, "User", "Pass", "SMPP", TypeOfNumber.UNKNOWN,
                NumberingPlanIndicator.UNKNOWN, null));
    Random random = new Random();

    final int totalSegments = 3;
    OptionalParameter sarMsgRefNum = OptionalParameters.newSarMsgRefNum((short) random.nextInt());
    OptionalParameter sarTotalSegments = OptionalParameters.newSarTotalSegments(totalSegments);

    for (int i = 0; i < totalSegments; i++) {
        final int seqNum = i + 1;
        String message = "Message part " + seqNum + " of " + totalSegments + " ";
        OptionalParameter sarSegmentSeqnum = OptionalParameters
                .newSarSegmentSeqnum(seqNum);
        String messageId = session.submitShortMessage("CMT", TypeOfNumber.INTERNATIONAL,
                NumberingPlanIndicator.UNKNOWN, "919999999999", TypeOfNumber.INTERNATIONAL,
                NumberingPlanIndicator.UNKNOWN, "919999999999", new ESMClass(),
                (byte) 0, (byte) 1, timeFormatter.format(new Date()), null,
                new RegisteredDelivery(SMSCDeliveryReceipt.DEFAULT), (byte) 0,
                new GeneralDataCoding(false, false, MessageClass.CLASS1,
                        Alphabet.ALPHA_8_BIT), (byte) 0, message.getBytes(),sarSegmentSeqnum, sarTotalSegments, sarMsgRefNum);
        System.out.println("Message submitted, message_id is " + messageId);
    }
    session.unbindAndClose();
}

But this code doesn't seem to work. What I receive is messages split up in different messages and not concatenated on the handset.

Any pointers on what am I doing wrong here.

Tailor answered 11/1, 2011 at 17:16 Comment(1)
I suggest you get a network trace of the sending with Wireshark. It has a great SMPP protocol handler that will show all the flags and options of the packets. If you still have problems post the details and I might be able to help.Neptunium
W
1

Raks,

Remember that not all networks in the world, nor all handsets in the world are configured correctly for sending/receiving the multi-part SMS messages.

As you have (rightly) disguised your actual SMSC connector, i'm not sure which carrier/aggregator you connect to. Therefore i can't comment if this is the problem in your specific situation.

But as Alexrs said, include the TCP Dump output and we can at least comment on the correct output coming from your app.

Wardmote answered 3/6, 2011 at 17:42 Comment(1)
Even on carriers and phones that I know supports multipart messages (having both sent and received them), I still have this problem of multi-part messages being received as several single messages when sent with code similar to the above.Bolus

© 2022 - 2024 — McMap. All rights reserved.