gnilatkar / jsmpp

Automatically exported from code.google.com/p/jsmpp
Apache License 2.0
0 stars 0 forks source link

Problem in sending optional parameter its_session_info #76

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Hello,
Hi,

In my USSD application I need to send the its_session_info and ussd_service_op 
optional parameters for interactive session USSD message. But as per the 
wireshark trace it is showing that SMPP Packet is malformed, and i'm getting 
this error only when i am sending the its_session_info optional parameter with 
byte value and it is affecting ussd_service_op also at the same time. If the 
its_session_info is sent using short value everything works fine but without 
any session number in the SMPP Packet whic is actually required. 

Below is my code in which i'm appending optional parameters to SMPP Packet;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ussdsmpp;

import java.io.IOException;

import org.jsmpp.InvalidResponseException;
import org.jsmpp.PDUException;
import org.jsmpp.bean.Alphabet;
import org.jsmpp.bean.BindType;
import org.jsmpp.bean.ESMClass;
import org.jsmpp.bean.GeneralDataCoding;
import org.jsmpp.bean.MessageClass;
import org.jsmpp.bean.NumberingPlanIndicator;
import org.jsmpp.bean.RegisteredDelivery;
import org.jsmpp.bean.SMSCDeliveryReceipt;
import org.jsmpp.bean.TypeOfNumber;
import org.jsmpp.extra.NegativeResponseException;
import org.jsmpp.extra.ResponseTimeoutException;
import org.jsmpp.session.BindParameter;
import org.jsmpp.session.SMPPSession;
import org.jsmpp.util.AbsoluteTimeFormatter;
import org.jsmpp.util.TimeFormatter;
import org.jsmpp.bean.OptionalParameter;
import org.jsmpp.bean.OptionalParameter.Tag;

public class USSD
{

   private static TimeFormatter timeFormatter = new AbsoluteTimeFormatter();

    public static void main(String[] args)
    {
        SMPPSession session = new SMPPSession();

        int i = 2;
        short j=1;
        OptionalParameter op1 = new OptionalParameter.Byte(Tag.USSD_SERVICE_OP, (byte) i);
        //OptionalParameter op2 = new OptionalParameter.
        OptionalParameter op2 = new OptionalParameter.Byte(Tag.ITS_SESSION_INFO, (byte)2);
        OptionalParameter op[] = new OptionalParameter[2];
        op[0] = op2;
        op[1] = op1;

        //OptionalParameter op2 = new OptionalParameter.Byte(Tag.ITS_SESSION_INFO, (byte) 3);
        //OptionalParameter opits[] = new OptionalParameter[1];
        //opits[0] = op2;
        try
        {
         session.connectAndBind("xx.xxx.xxx.xx", xxxx, new BindParameter(BindType.BIND_TRX, "xxxx", "xxxx", "xxxx", TypeOfNumber.UNKNOWN, NumberingPlanIndicator.ISDN, "xxx"));
        }catch(IOException ioe)
        {
            System.out.println("Failed connect and bind to host");
            ioe.printStackTrace();
        }

        try
        {
          String messageId = session.submitShortMessage("USSD", TypeOfNumber.ALPHANUMERIC, NumberingPlanIndicator.PRIVATE, "xxx", TypeOfNumber.INTERNATIONAL, NumberingPlanIndicator.ISDN, "xxxxxxxxxx", new ESMClass(), (byte)0, (byte)0, null, null, new RegisteredDelivery(SMSCDeliveryReceipt.DEFAULT), (byte)0, new GeneralDataCoding(false, false, MessageClass.CLASS0, Alphabet.ALPHA_DEFAULT), (byte)0, "TEST".getBytes(),op);
        }catch(PDUException e)
        {
            System.out.println("Invalid PDU parameter");
            e.printStackTrace();
        } catch (ResponseTimeoutException e) {
            // Response timeout
            System.err.println("Response timeout");
            e.printStackTrace();
        } catch (InvalidResponseException e) {
            // Invalid response
            System.err.println("Receive invalid respose");
            e.printStackTrace();
        } catch (NegativeResponseException e) {
            // Receiving negative response (non-zero command_status)
            System.err.println("Receive negative response");
            e.printStackTrace();
        } catch (IOException e) {
            System.err.println("IO error occur");
            e.printStackTrace();
        }

           session.unbindAndClose();
    }

}

And Below is the SMPP frame captured from wireshark;

0000  00 01 7a 09 d6 d3 00 13  20 23 c8 e5 08 00 45 00   ..z.....  #....E.
0010  00 6a 65 05 40 00 80 06  99 75 c0 a8 01 97 3b a1   .je.@... .u....;.
0020  fe 32 08 64 0b c1 4d c7  77 0a ca 7c 0f 8a 50 18   .2.d..M. w..|..P.
0030  ff e9 25 ce 00 00 00 00  00 42 00 00 00 04 00 00   ..%..... .B......
0040  00 00 00 00 00 02 55 53  53 44 00 05 09 33 36 37   ......US SD...367
0050  00 01 01 39 31 39 37 34  31 37 37 37 30 34 31 00   ...91974 1777041.
0060  00 00 00 00 00 00 00 00  00 04 54 45 53 54 13 83   ........ ..TEST..
0070  00 01 02 05 01 00 01 02                            ........         

optional parameter: its_session_info (0x1383)
                    Tag: 0x1383
                    Length: 1
                    session number: 2
                    0000 010. = sequence number : 0x02
                    ........1 = session indicator: End of session    indicator active (0x01)

optional parameter: 0x0100 (0x0100)
                    Tag: 0x0100
                    Length: 258

[Malformed Packet: SMPP]

I am using JSMPP 2.1.0 version.

Kindly help me out in this regard.

Original issue reported on code.google.com by chethan7...@gmail.com on 11 Aug 2010 at 11:10

GoogleCodeExporter commented 8 years ago
Hi 
Kindly let me know if you have got the solution for your query.

Thanks

Original comment by gurleen....@gmail.com on 11 Jan 2012 at 1:20

GoogleCodeExporter commented 8 years ago
I have the same problem but with RECEIPTED_MESSAGE_ID parameter.

Original comment by sokun...@gmail.com on 12 Mar 2012 at 10:38

GoogleCodeExporter commented 8 years ago
Hi,

Same problem for me with version 2.1.0. Please let me know if you already have 
a solution for this.

Original comment by omasamp...@gmail.com on 20 Sep 2013 at 11:29