How to select bind_type to the SMSC ( TX/RX/TRX)- (solved)

Aug 2, 2011 at 1:29 PM

Hi Ben,

as you mentioned the way how the bind type can be selected, I tried to reproduce your advice and I come to the point where I could need your help.

You said ( in my previous discussion): "By default, Jamaa SMPP Client library binds as TRX using ver 3.4 protocol. To change this behavior, change the interface version to version 3.3 as shown below:"

SmppClient xclient = new SmppClient();
SmppConnectionProperties prop = xclient.Properties;
prop.InterfaceVersion = InterfaceVersion.v33;        
//Specify other connection details here
OK so far so good, but here I don't see the posibility to select the bind type (TX, TRX, RX).
Please addsome code rows which show the selecting. How to use it? So somehow or how?
prop.BindAsThatWhatYouWish = TX; // or so somehow :-)
thanks
regards
Codexer  
Coordinator
Aug 3, 2011 at 10:37 AM

Hello Codexer,

Jamaa SMPP Client will transparently choose the type of binding for you depending on the selected protocol version. As you may have noticed, the SmppClient class is simply a wrapper on the SmppClientSession class, which provides the actual implementation of the SMPP protocol.

If SMPP protocol version 3.4 is selected, the SmppClient will create a single instance of the SmppClientSession class, for both transmitting and receiving PDUs. On the other hand, if you specify SMPP protocol version 3.3, the SmppClient will create TWO instances of the SmppClientSession class, one for transmitting and one for receiving. This process is handled transparently, and it's something you wouldn't normally worry about.

According to SMPP version 3.3 specifications, you will need two separate sessions for sending and receiving PDU's - which was changed in version 3.4. Jamaa SMPP Client will create two sessions whenever the interface version is set to ver3.3 and you can send/receive messages the same way as you would with ver3.4.

The bottom line is: The SmppClient class works the same way regardless of which interface version is selected. The session creation is being handled for you, and it is something you shouldn't be concerned with (most of the time though).

However, the version 3.3 implementation has not been tested thoroughly due to lack of support for this version. If your end point supports version 3.4, we highly recommend that you use it instead.

Ben

Aug 3, 2011 at 2:06 PM
Edited Aug 3, 2011 at 2:14 PM

Hi Ben,

Thanks for this info. It's clear now.  3.4 for TRX and 3.3 for TX/RX. That's fine that this lib takes the chossing of using bind type. I can live with that. :-)

But I'm not sure that missed flexibility ( concerns selecting TX,RX,TRX) would be appreciated by another people... who nows... Why do I say that? Hm... There are many SMSCs which allow either TX&RX or TX/RX/TRX or just TRX and uses interface version = 52 (3.4). And if I now have on example to send some messages to the SMSC which doesn't support version 3.3 and I should bind to them using TX/RX ( because they do have just TX/RX or want to have that due to selecting of MO & MT msgs).... What can I do then? Nothing. That is what I'm trying to say. Flexibilitiy ( like other smpp libs) is very appreciated... Let the user choose that what he want and he is happy.... But how I said, I can live with that...

regards

Codexer

 

Aug 3, 2011 at 2:25 PM

 

Hi Ben,

I can't stop thinking about that... :-)

Is it possible to modify ( I'll do that, just tell me where is the point in lib-code) the lib to avoid this behaviour?

thanks

nice day

Codexer

Aug 3, 2011 at 4:46 PM

Hi Ben,

I found this in the "SmppClientSession.cs":

 private void BindSession(SessionBindInfo bindInfo, int timeOut)
        {
            vTcpIpSession.SessionClosed += TcpIpSessionClosedEventHandler;

            BindRequest bindReq = bindInfo.CreatePdu();
            vTrans.Send(bindReq);
            BindResponse bindResp = null;
            try { bindResp = (BindResponse)vRespHandler.WaitResponse(bindReq, timeOut); }
            catch (SmppResponseTimedOutException ex)
            { throw new SmppBindException(ex); }
            if (bindResp.Header.ErrorCode != 0)
            { throw new SmppBindException(bindResp.Header.ErrorCode); }
            //Copy settings
            vSmscId = bindResp.SystemID;
            vSystemId = bindInfo.SystemID;
            vPassword = bindInfo.Password;
            vAddressTon = bindInfo.AddressTon;
            vAddressNpi = bindInfo.AddressNpi;
            //Start timer
            vTimer.Start();
            vIsAlive = true;
            switch (bindReq.Header.CommandType)
            {
                case CommandType.BindTransceiver:
                    ChangeState(SmppSessionState.Transceiver);
                    break;
                case CommandType.BindReceiver:
                    ChangeState(SmppSessionState.Receiver);
                    break;
                case CommandType.BindTransmitter:
                    ChangeState(SmppSessionState.Transmitter);
                    break;
            }
        }

Could it solve my problem about TX,RX,TRX? could I use this method somehow? :-)
thanks
regards
Codexer
Coordinator
Aug 3, 2011 at 5:27 PM

Codexer,

Jamaa SMPP was designed to offer maximum flexibility for even most complex requirements you can think of. As far as it is supported in the SMPP protocol, Jamaa SMPP should definitely be able to do it.

What is important to understand is the choice of the library to use in your implementation as Jamaa SMPP Client is a set of two libraries: JamaaTech.Smpp.Net.Lib and JamaaTech.Smpp.Net.Client

The later is a wrapper of the other and is meant to abstract protocol specific details that wouldn't be necessary for simple day-to-day implementations. But for complex requirements JamaaTech.Smpp.Net.Lib is definitely what you should use.

Follow the SmppClient class implementation carefully and inject your own custom code at any relevant points according to your requirements and you should be able to get any desired behavior you want.

As long as you understand the details of the SMPP protocol, it should be easy to navigate around. If you are not very familiar with SMPP protocol details, then stick to the JamaaTech.Smpp.Net.Client library. It will save you a great deal of time.

Hope that helps.

Ben

Aug 4, 2011 at 1:53 PM
Edited Aug 4, 2011 at 2:00 PM

Ben,

What can I say?  --- GREAT!!! - It works!!

I have used the JamaaTech.Smpp.Net.Lib only.  No wrapper lib has been used. And I was able to:  - 1. connect to the SMSC with bindtype TX only & while using 52, - 2. send a message using SubmitSm and TLV (self created Tag), -3. Unbind my client. All works as intended & expected!!! Thank you for your help in this case... !

And for all other people, here my code using JamaaTech.Smpp.Net.Lib only:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using JamaaTech;
using JamaaTech.Smpp;
using JamaaTech.Smpp.Net;
using JamaaTech.Smpp.Net.Lib;
using JamaaTech.Smpp.Net.Lib.Networking;
using JamaaTech.Smpp.Net.Lib.Protocol;
using JamaaTech.Smpp.Net.Lib.Util;
using JamaaTech.Smpp.Net.Lib.Protocol.Tlv;

namespace SMPPMM
{
    public partial class Form1 : Form
    {
        SmppClientSession mmSession;    
        SubmitSm mmSubmitSm; 
        SubmitSmResp mmSubmitSmResp;      
        SessionBindInfo mmSessionBindInfo;      
        Unbind mmUnbind;
        UnbindResp mmUnbindResp;
        
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            mmSessionBindInfo = new SessionBindInfo(); // instanze of the sessionbindinfo
            mmSessionBindInfo.SystemID = "myusername"; // known settings, Username
            mmSessionBindInfo.Password = "myPW"; // // known settings, PW
            mmSessionBindInfo.ServerName = "111.111.111.11"; // known settings, where to bind...
            mmSessionBindInfo.Port = 4444; // known settings, port
            mmSessionBindInfo.InterfaceVersion = InterfaceVersion.v34; // 52
            mmSessionBindInfo.SystemType = "NET"; // system type
            mmSessionBindInfo.AllowTransmit = true; // I want to bind as TX only ( while using  52), - THANKS Ben, it works!!!
            mmSessionBindInfo.AllowReceive = false; // don't want his at the moment
            mmSessionBindInfo.AddressNpi = NumberingPlanIndicator.Unknown; //known settings
            mmSessionBindInfo.AddressTon = TypeOfNumber.Unknown; //known settings
            
            mmSession = SmppClientSession.Bind(mmSessionBindInfo, 0); // my session, bind to the server with all available bindinfos

            richTextBox2.Text = "Connected to:  "+ mmSession.SmscID +"\n"; // the name of the server where you are going to connect to...
            richTextBox2.Text += "Session state: "+ mmSession.State +"\n";   // state of the session....     
        }

        private void button2_Click(object sender, EventArgs e)
        {
            string tlvValue = "22164"; //This is my tlv value
            byte[] tlvBytes = SMPPEncodingUtil.GetBytesFromString(tlvValue); //Convert the string to bytes to use with Tlv
            Tlv TLV_APP_ID = new Tlv(JamaaTech.Smpp.Net.Lib.Protocol.Tlv.Tag.tlv_app_id, 0); // create new Tag (was not in the smpp 3.4)
            TLV_APP_ID.ParseValue(tlvBytes); // add the value 22164 to this Tag

            mmSubmitSm = new SubmitSm(); // instance of the SubmitSm

            mmSubmitSm.ServiceType = "CMT"; // cellular  messaging
            mmSubmitSm.RegisteredDelivery = RegisteredDelivery.DeliveryReceipt; // MT delivered? wanna know... :-)
            mmSubmitSm.EsmClass = EsmClass.Default; // leave it default at the moment...
            mmSubmitSm.DestinationAddress.Address = "49123456789"; // destination
            mmSubmitSm.DestinationAddress.Npi = NumberingPlanIndicator.Unknown; // known settings
            mmSubmitSm.DestinationAddress.Ton = TypeOfNumber.Unknown; // known settings
            mmSubmitSm.SourceAddress.Npi = NumberingPlanIndicator.Unknown; // known settings
            mmSubmitSm.SourceAddress.Ton = TypeOfNumber.Unknown; // known settings
            mmSubmitSm.Tlv.Add(TLV_APP_ID); //  add "self made" Tag to the submitsm
            mmSubmitSm.SetMessageText("Test message Nr. 3 from Codexer", DataCoding.SMSCDefault); // message content with coding

            mmSubmitSmResp = mmSession.SendPdu(mmSubmitSm) as SubmitSmResp; // send PDU

            richTextBox3.Text = mmSubmitSmResp.MessageID  + "\n"; // show message ID
            richTextBox3.Text += mmSubmitSmResp.Header.ErrorCode.ToString()+"\n";  // any error code there? No, all went OK :-)         
        }

        private void button3_Click(object sender, EventArgs e)
        {
              mmUnbind = new Unbind(); // instance of the unbind
              mmUnbindResp = mmSession.SendPdu(mmUnbind) as UnbindResp; // unbind

              richTextBox4.Text += mmUnbindResp.Header.CommandType.ToString() + "\n"; // just to know what has been sent
              richTextBox4.Text = mmUnbindResp.Header.ErrorCode.ToString()+"\n"; // and did it work as intended...
        }
        
    }
}

 

Ben,  thank you !!! Nice day.....

regards

Codexer

Coordinator
Aug 4, 2011 at 2:01 PM

Codexer,

Nice to hear that it worked flawlessly.

Ben

Jun 13, 2013 at 1:55 PM
Dears,
I used for testing the Codes but Always Display the Following Error.
Object reference not set to an instance of an object
On the Part of Code :
mmSubmitSmResp = (mmSession.SendPdu(mmSubmitSm)) as SubmitSmResp;

Please Your Advice
Dec 30, 2013 at 5:17 PM
bentesha wrote:
Codexer, Jamaa SMPP was designed to offer maximum flexibility for even most complex requirements you can think of. As far as it is supported in the SMPP protocol, Jamaa SMPP should definitely be able to do it. What is important to understand is the choice of the library to use in your implementation as Jamaa SMPP Client is a set of two libraries: JamaaTech.Smpp.Net.Lib and JamaaTech.Smpp.Net.Client The later is a wrapper of the other and is meant to abstract protocol specific details that wouldn't be necessary for simple day-to-day implementations. But for complex requirements JamaaTech.Smpp.Net.Lib is definitely what you should use. Follow the SmppClient class implementation carefully and inject your own custom code at any relevant points according to your requirements and you should be able to get any desired behavior you want. As long as you understand the details of the SMPP protocol, it should be easy to navigate around. If you are not very familiar with SMPP protocol details, then stick to the JamaaTech.Smpp.Net.Client library. It will save you a great deal of time. Hope that helps. Ben
Hi Ben,

I tried and implement it and it works great. But it is sending one sms in 3 seconds even though from provider I have 10sms per second. But here it is able to send 1 sms in 3 seconds. Please if someone can advise me what is the problem or what should I change I will appreciate it a lot.

Thanks in advance
Jul 30, 2014 at 12:00 PM
Dear sir,
I am new to c# and I have no idea about SMPP.
I am doing a project currently to send sms and was happy to find your code.
I copied the code and getting the following error.
Please help me at your earliest.
Your help is highly appreciated.

'JamaaTech.Smpp.Net.Lib.Protocol.Tlv.Tag' does not contain a definition for 'tlv_app_id' \Form1.cs 58 78 WindowsFormsApplication1

Tlv TLV_APP_ID = new Tlv(JamaaTech.Smpp.Net.Lib.Protocol.Tlv.Tag.tlv_app_id, 0); // create new Tag (was not in the smpp 3.4)

Thank you very much for your help
prasanna_lanka@yahoo.co.uk