asikcse / jsmpp

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

Problem in sending optional parameter its_session_info #75

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 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:09

GoogleCodeExporter commented 9 years ago

The length of its_session_info
should be 2,yours is 1

Parameter Tag 2 Integer its_session_info
Length 2 Integer Length of Value part in octets
Value 2 Octet
String Bits 7...............0
SSSS SSSS (octet 1)
NNNN NNNE (octet 2)
Octet 1 contains the session number (0 -
255) encoded in binary. The session
number remains constant for each session.
The sequence number of the dialogue unit
(as assigned by the ESME) within the
session is encoded in bits 7..1 of octet 2.

Original comment by changmen...@gmail.com on 3 Aug 2011 at 5:00

GoogleCodeExporter commented 9 years ago
its_session_info should use OctetString so please use

new OptionalParameter.OctetString(OptionalParameter.Tag.ITS_SESSION_INFO, new 
byte[]{x, y})

Original comment by uuda...@gmail.com on 7 Aug 2011 at 10:19

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Hello,
I have the same problem but with Tag.RECEIPTED_MESSAGE_ID. Always my wireshark 
set my deliver_sm as Malformed.
I add OptionalParameter like this:
OptionalParameter op[] = new OptionalParameter[2];
OptionalParameter op1 = new OptionalParameter.Byte(Tag.MESSAGE_STATE, (byte) 2);

OptionalParameter op2 = new 
OptionalParameter.OctetString(Tag.RECEIPTED_MESSAGE_ID.code(), 
messageId.toString().getBytes());
op[0] = op1;
op[1] = op2;
And I add it into deliver_sm
session.deliverShortMessage(..., op);
I try to add RECEIPTED_MESSAGE_ID like Int or Byte but always have the same 
result Malformed Packet:SMPP.
Please help me to carry out this problem.

Original comment by sokun...@gmail.com on 11 Mar 2012 at 6:37