How to read messages/replies from the SMS Gateway?

Aug 12, 2011 at 8:31 AM

Dear Codexer,

sorry I'm a newbie in SMS Gateway...

With the given example, I was able to send SMS messages to an SMS Gateway..

However, with the given example, I could not comprehend the "Inbox" structure of the received messages/replies in the SMS Gateway..

With the given sample code I could not understand how to fetch and read each "replies/messages received" one by one for me to process each reply and change its state so my program will not read it again.

Do you have a more thorough sample code that shows how to read messages (or replies from user) from the SMS Gateway?

You reply is very much appreciated..

Many Thanks and Best Regards,

Jojo

Aug 12, 2011 at 1:36 PM

Hi Jojo,

 

It would be interesting fpr me too. I guess Ben could give some lights in this problem.

I was interesting in the connection to the SMSC and how one can send messages (MT), but for receiving ( MO or DLR) I didn't have enough time for that. I was using some months ago other libs and there was no problem to receive the MOs or DLRs. It was enough to bind to te SMSC using RX and all DLR were displayed in a output window. but how it could be used in this lib... ?  

Beeeenn !!!! please help. That's the next step what I'm going to use in my "smpp-connector" proggi. According to the following lines in der guide (Jamaa) ...:...

->To receive messages, handle the SmppClient.MessageReceived event as follows:

SmppClient client = GetSmppClient();
client.MessageReceived += client_MessageReceived;

 

private void client_MessageReceived(object sender, MessageEventArgs e)
{
    TextMessage msg = e.ShortMessage as TextMessage;
    MessageBox.Show(msg.Text); //Display message
}
... it should not be a problem. But when using just the *.net.lib, it is not enough clear how to use it.
Ben, please be so kind and provide the way how to receive the MOs & DLRs (Callback).
Thank you & nice day.
Codexer
Coordinator
Aug 14, 2011 at 8:16 AM
Edited Aug 15, 2011 at 12:16 PM

Hello guys,

Sorry for a bit late reply.

When a text message is received, the SmppClient class will raise the SmppClient.MessageReceived event. Unlike in other SMPP Libraries, you don't need to keep polling for incoming messages, instead 

you provide a handler method for the MessageReceived event which gets invoked every time you have an incoming sms.

Note, you handler method gets called by a random thread-pool thread. Be sure to protect you code from thread racing conditions.

Below is a code snippet demonstrating how to both receive and send messages with Jamaa Smpp Library.

  void foo()
  {
    SmppClient client = new SmppClient();
    SmppConnectionProperties properties = client.Properties;
    //configure your smpp client
    properties.Host = "mygatewayhost";

    //specify other properties are required
    //Provide a handler for the SmppClient.MessageReceived event

    client.MessageReceived += new EventHandler<MessageEventArgs>(client_MessageReceived);
    //Connect to the gateway by starting the client

    client.Start();
    //send a message
    TextMessage textMsg = new TextMessage();
    textMsg.Text = "Hello, this is my message!";
    textMsg.DestinationAddress = "3883883833";
    textMsg.SourceAddress = "338833";
    //Specify other properties as required
    //Send message
    client.SendMessage(textMsg);
  }
  //This handler will be called every time we receive a message from a gateway
  public void client_MessageReceived(object sender, MessageEventArgs e)
  {
    //The event argument e contains more information about the received message
    TextMessage textMsg = e.ShortMessage as TextMessage; //This is the received text message
    string msgInfo = string.Format("Sender: {0}, Receiver: {1}, Message content: {2}", textMsg.SourceAddress, textMsg.DestinationAddress, textMsg.Text);
    //Display message
    MessageBox.Show(msgInfo);
  }
Aug 15, 2011 at 12:05 PM

Dear Ben and Codexer,

Thank you very much for you reply..

I tried your suggested code but I am facing this issue:

When I try to set value for properties.SmscID is says that I cannot assign value because its read-only..

So I commented this line of code and was able to Build my sample Windows Form. And instead I used and indicated the properties.SystemID, properties.Password, properties.Host and properties.Port...

I'm still able to send SMS and it seems to have no problem Invoking the EventHandler<MessageEventArgs> from a button as I call the void foo() function.

but I was able to receive or view any of my SMS Replies.

Do I need to indicate the SessionState as Transceiver? How do I do that?

Many Thanks and Best Regards,

Jojo

Coordinator
Aug 15, 2011 at 12:16 PM

Hi Joarkeryon,

The SmscID property is ready only and cannot be set. This is my mistake in the code snippet, sorry for any inconvenience this may have caused you.

You don't need to specify the session as Transceiver, that is being handled automatically for you.

If Smpp V3.4 is specified, the client automatically defaults to a transceiver mode and creates one underlying session for both sending and receiving. On the other hand, if Smpp v3.3 is specified, the client

switches to transceiver/receiver mode in which case, two underlying separate sessions are used, one for receiving and the other for sending pdu's.

What is fascinating is that, the whole process is transparent and you don't need to do anything implicitly.

Unless I didn't understand your question, I hope this helps.

Ben

Aug 17, 2011 at 4:07 AM
Edited Aug 22, 2011 at 10:21 AM

Dear Ben,

Your code is tested to be working successfully..
Thank you so much for your help..
Now I got the idea.

The EventHandler<MessageEventArgs> acts as a listener and when the SMS Gateway received any message to the specified properties.SystemID/DestinationAddress that I am using,

I receive the text message or replies instantaneously... 

Initially there was a problem with the SMS Gateways settings that was why we don't see any traffic and in my program I cannot see any of the replies I sent to the SMS GW..

Thank you so much guys for your kindness and generosity..

Best Regards,

Jojo

Coordinator
Aug 17, 2011 at 4:59 AM

Jojo,

Anytime!

Please don't forget to leave your feedback on our library!

Ben

Sep 1, 2011 at 11:13 AM
Edited Sep 1, 2011 at 11:15 AM

Hi Ben,

Sorry to botter you again concerning the receiving messages from SMSC. I know that it will work if I use the "JamaaTech.Smpp.Net.Client" lib. All what I need is: how to receive messages using only the lib: "JamaaTech.SMPP.Net.Lib"...  could you please provide an example of using this lib to receive the messages from SMSC? please...

I guess it would be so:

//other known settings
SmppClientSession mmSession;
...
mmSessionBindInfo = ....
...
mmSession = SmppClientSession.Bind(mmSessionBindInfo, 0); // my session, bind to the SMSC



mmSession.PduReceived += new
EventHandler<PduReceivedEventArgs>(mmSession_PduReceived);

public void mmSession_PduReceived(object sender, PduReceivedEventArgs e)
        {
            MessageBox.Show(e.?????? ); // or how??
        }

Is it correct?  or do I have to modify the lib somehow?

thank you Ben...

nice day

regards

Codexer

 

Coordinator
Sep 7, 2011 at 3:25 AM

Hi Codexer,

Sorry for a late reply. I thought I had already replied to this. Below is what should be your implementation for the PduReceived event handler.

 

private void PduReceivedEventHander(object sender, PduReceivedEventArgs e)

{

SingleDestinationPDU pdu = e.Request as SingleDestinationPDU;

if(pdu == null) { return; } //If you want to custom process all PDUs, replace this line with your custom logic

Udh udh = null; //We need to test if the UDH field is present

string message = null; //This will hold the message text

pdu.GetMessageText(out message, out udh); //Get message text and UDH from the PDU

//if(udh != null) { /*Then UDH is defined*/}

//else { /*No UDH has been defined*/ }

string sourceAddress = pdu.SourceAddress.Address; //Message source address

string destinationAddress = pdu.DestinationAddress.Address; //Message destination address

//.. the rest of your application code goes here

}

 

Hope this helps!

Ben

Sep 7, 2011 at 7:22 AM

Hi Ben,

 

Many Thanks for your answer!!!!! I'll try it and will let you know how it works.. additionaly, it's the last issue ( on my side) concerning the using of your great lib!

Ben, nice day!

cheers

Codexer

Coordinator
Sep 7, 2011 at 8:08 AM

Codexer,

Anytime, you are welcome!

Ben

Sep 9, 2011 at 10:17 AM

HI Ben,

Somehow I can't get it working... the pdu which should contain at least the DLR (Callback) of delivered message ( Iknow the message is delivered as I received the message on handset) butthere is nothing in this pdu. this pdu is allways null!!! Why? what I'm doing wrong here? :-(  Is there still something to modify in the code provided from you? Here the whole code of my program that's working perfektly for me (included the posibility for sending of concatenated messages) except the receiving of DLR (or MO). How I said it's the last issue which I em not able to resolve. I have implemented the (from you) provided handler-code but it seems not to work. I'm geting following error in our (production) smpp-server:

[2011-09-07 15:50:29.02734] [root SMPP-Server-v2.49 conn02 29788] [INFO]  (mysmppaccount) error deliver_sm_resp
[2011-09-07 15:50:29.02797] [root SMPP-Server-v2.49 conn02 29788] [INFO]  (mysmppaccount)
$VAR1 = bless( {
                 'known_pdu' => 1,
                 'message_id' => '',
                 'cmd' => 2147483653,
                 'status' => 255,
                 'data' => '^@',
                 'reserved' => undef,
                 'seq' => 2
               }, 'Net::SMPP::PDU' );

 It seems that the status = 255 ( means unknown eror) is generated due to ( i guess, not sure) 'cmd'  = > 2147483653. Is it not the comandID wrong? I have posted it just to explain what our server is responsing. Please note that this is a produktion server which is working for years and with an another lib its is working ( the receiving of DLRs). And here the Code ( complette) which I'm using :

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;
        Udh mmUdh;
        Random mrandom = new Random();
       

        public Form1()
        {
            InitializeComponent();          
        }
 
        private void button1_Click(object sender, EventArgs e)
        {
            mmSessionBindInfo = new SessionBindInfo(); // instanze of the sessionbindinfo
            mmSessionBindInfo.SystemID = "mysmppaccount";// "mysmppaccount"; // known settings, Username
            mmSessionBindInfo.Password = "myPW"; // "myPW"; // // known settings, PW
            mmSessionBindInfo.ServerName = "194.111.111.11"; // "194.111.111.1"; // known settings, where to bind...
            mmSessionBindInfo.Port = 1234; // 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 = true; // 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";

            mmSession.PduReceived += new EventHandler<PduReceivedEventArgs>(mmSession_PduReceived); // event handler
                    
        }

        void mmSession_PduReceived(object sender, PduReceivedEventArgs e)
        {
            SingleDestinationPDU pdu = e.Request as SingleDestinationPDU;
            if (pdu == null) { return; } //If you want to custom process all PDUs, replace this line with your custom logic
            Udh udh = null; //We need to test if the UDH field is present
            string message = null; //This will hold the message text
            pdu.GetMessageText(out message, out udh); //Get message text and UDH from the PDU
            /* this pdu is ALLWAYS null!!!! nothing there... :-( 
             There should be at least the DLR ( Callback) of delivered message.
             */
            //if(udh != null) { /*Then UDH is defined*/}
            //else { /*No UDH has been defined*/ }
            string sourceAddress = pdu.SourceAddress.Address; //Message source address
            string destinationAddress = pdu.DestinationAddress.Address; //Message destination address
            //.. the rest of your application code goes here
            MessageBox.Show(message + "\n" + sourceAddress + "\n" + destinationAddress + "\n"); // show some infos about incoming pdu          
        }

        private void button2_Click(object sender, EventArgs e)
        {
            mmSubmitSm = new SubmitSm();

            mmSubmitSm.ServiceType = "CMT"; // cellular  messaging
            mmSubmitSm.RegisteredDelivery = RegisteredDelivery.DeliveryReceipt; // MT delivered? wanna know... :-)
            mmSubmitSm.EsmClass = EsmClass.UdhiIndicator; // leave it default at the moment...
            mmSubmitSm.DestinationAddress.Address = "491234567890"; // 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
  
            
            const string minput = "MSG 2: Ich bin nur ein einfacher Musikant der sehr schlecht spielt aber einen guten Willen hat. Das ist aber denen zu wenig, die wollen mehr haben. Mehr geht es aber nicht, ich kann das was ich kann und das ist es!";
            string[] splittedMsg = mmTools.SplitSpecial(minput, 153); // my own funktion to split the message

            int SegID = mrandom.Next(1000, 9999); // generate random ID
            int totalSegments = splittedMsg.Length; // how many segments are there

            mmUdh = new Udh(SegID, totalSegments, 0); //initialize udh
            mmUdh.MessageCount = totalSegments;  // message count

            for (int i = 0; i < totalSegments; i++)
            {
                mmUdh.MessageSequence = i + 1;   // next part     
                mmSubmitSm.SetMessageText(splittedMsg[i], DataCoding.SMSCDefault, mmUdh); // set message text(part of message)
                mmSubmitSmResp = mmSession.SendPdu(mmSubmitSm) as SubmitSmResp; // send PDU 

                richTextBox3.Text += mmSubmitSmResp.MessageID + "\n"; // show message ID
                richTextBox3.Text += mmSubmitSmResp.Header.ErrorCode.ToString() + "\n";   // if any error....
            }          
        }

        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...
        }
    }
}

 

Could you please check this code if something is missing there orif it should be modified?

Thank you Ben!

regards

Codexer

Coordinator
Sep 13, 2011 at 5:22 AM

HI Codexer,

Sorry for a late reply. I have been a bit busy recently and haven't been able to get back to you in time.

I am trying to understand why the server doesn't report this kind of error when you use the SmppClient class. Is this the same server you used the SmppClient lib successfully with?

Note: Any PDU that can't be cast to type SingleDestinationPDU will result into the pdu being null, which is expected, and that's why we have this line:

if(pdu == null) { return; }

Your comments "this pdu is always null" is far down below this line and I can't understand what exactly you mean by the "pdu being null" (since this is expected, but will not always be null).

Do you mean that the pdu is "empty" and doesn't contain the data you expected? Please clarify on this.

Sep 13, 2011 at 7:43 AM
Edited Sep 13, 2011 at 8:17 AM

HI Ben,

Nice to hear from you! :-) I know you're having other responsibilities too. Doesn' matter if I wait for your answer.... Main thing is - you give me an answer... :-)

So, the code line: "if(pdu == null) { return; }" is OK. I understand that if this pdu is null ( that means: no data inside the pdu) the system will return. This is OK so and should be so. But, I did some checks for the content of this pdu and I put the comment sign "//" for this line: "if(pdu == null) { return; }". after that the system ( my proggi) hang and  I see in debugger that the pdu is null. It is somehow not clear why there is no DLR which I have had to receive ( the MT has been delivered to my handset). I also put the messagebox.show after the line"if pdu is null":

 SingleDestinationPDU pdu = e.Request as SingleDestinationPDU;          
            if (pdu == null) 
            {
                MessageBox.Show("The received pdu does not contain any data!");
                return; 
            } //If you want to custom process all PDUs, replace this line with your custom logic
To be honest I never tried to use the client lib (I used always the "JamaaTech.Smpp.Net.Lib.v1.4.dll") as the client lib doesn't have other properties which could be set ( submitSm...). 
And another reason for not using the client lib is that there is a code segment which is not recognizable from the cleint lib: "GetSmppClient()" ( descriebed in the Guide from you):

->To receive messages, handle the SmppClient.MessageReceived event as follows:

SmppClient client = GetSmppClient();
client.MessageReceived += client_MessageReceived;
I would say, if you could provide the some solution for receiving of DLR(Callbacks), because you wrote: " if (pdu == null) { return; } //If you want to custom process all PDUs, replace this line with your custom logic
If I would process all PDUs how does the code segment look for DLR(or received MO)? Could you please post the here the sample code (of the EventHandler<PduReceivedEventArgs>) for which you are 100% sure that it works on your side? :-)
Because I will then search for error in my proggi( as the event handler is working on your side).
Is the reason for "pdu is null" that the "deliverSmResponse" is not sending back to the server or the server doesn't recognize the received response (deliversmResponse) as the server is writing ( how you can see in posted lines):
 
[2011-09-07 15:50:29.02734] [root SMPP-Server-v2.49 conn02 29788] [INFO]  (mysmppaccount) error deliver_sm_resp
[2011-09-07 15:50:29.02797] [root SMPP-Server-v2.49 conn02 29788] [INFO]  (mysmppaccount)
$VAR1 = bless( {
                 'known_pdu' => 1,
                 'message_id' => '',
                 'cmd' => 2147483653,
                 'status' => 255,
                 'data' => '^@',
                 'reserved' => undef,
                 'seq' => 2
               }, 'Net::SMPP::PDU' );



In which case could the error deliver_sm_resp be generated and will have the 'status' => 255? Ans as you can see the line: 'data' => '^@', there are no correct data containig in the deliversm response.
Somehow there is mistery what went wrong...
But I guess it is the best I try to get it working with the simple code using the "client lib" first. If I can get the DLR received with the client lib and with the "...Lib.lib" not, then is something there in my proggi what is causing a problem with receiving of the DLRs.
So Ben, how I said if you could check the event handler(EventHandler<PduReceivedEventArgs>) for ev. changes which should be done( or in my proggi, the whole code is posted above :-)) to be able to receive the DLRs and give me an answer, it would be nice.
In the meantime I will try to get the DLRs using the "...client.lib" lib.
Thank you Ben, let me know if you need more infos.. how I said your libs are OK, it needs to be tested further and my last issue is the receiving of the MOs ( and DLRs)..
regards
Codexer
Sep 13, 2011 at 8:40 AM
Edited Sep 13, 2011 at 8:41 AM

Hi Ben,

Using the "JamaaTech.Smpp.Net.Client.v1.4.dll":

 

The same error (cut of our server log):

[2011-09-13 10:25:29.02734] [root SMPP-Server-v2.49 conn02 29788] [INFO]  (mysmppaccount) error deliver_sm_resp
[2011-09-13 10:25:29.02797] [root SMPP-Server-v2.49 conn02 29788] [INFO]  (mysmppaccount)
$VAR1 = bless( {
                 'known_pdu' => 1,
                 'message_id' => '',
                 'cmd' => 2147483653,
                 'status' => 255,
                 'data' => '^@',
                 'reserved' => undef,
                 'seq' => 2
               }, 'Net::SMPP::PDU' );


And here the code which I used:
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.Smpp.Net.Client;

namespace jammasimple
{
    public partial class Form1 : Form
    {
        SmppClient mmclient = new SmppClient();
        SmppConnectionProperties mmproperties;
        TextMessage mymsg = new TextMessage();

        public Form1() 
        {
            InitializeComponent();
            mmproperties = mmclient.Properties;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            mmproperties.SystemID = "mysmppaccount";
            mmproperties.Password = "mypw";
            mmproperties.Port = 1234; //IP port to use
            mmproperties.Host = "194.11.11.111"; //SMSC host name or IP Address
            mmproperties.SystemType = "NET";
            
            //Resume a lost connection after 30 seconds
            mmclient.AutoReconnectDelay = 3000;
            //Send Enquire Link PDU every 30 seconds
            mmclient.KeepAliveInterval = 30000;
            //Start smpp client
            mmclient.Start();
            //Provide a handler for the SmppClient.MessageReceived event
            mmclient.MessageReceived += new EventHandler<MessageEventArgs>(mmclient_MessageReceived);
        }

        //This handler will be called every time we receive a message from a gateway
        public void mmclient_MessageReceived(object sender, MessageEventArgs e) 
        {
            //The event argument e contains more information about the received message
            TextMessage textMsg = e.ShortMessage as TextMessage; //This is the received text message
            string msgInfo = string.Format("Sender: {0}, Receiver: {1}, Message content: {2}", textMsg.SourceAddress, textMsg.DestinationAddress, textMsg.Text);
            //Display message
            MessageBox.Show(msgInfo);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            mymsg.DestinationAddress = "491234567890"; //Receipient number
            mymsg.SourceAddress = "4367622222222"; //Originating number
            mymsg.Text = "Hello, this is my simple client test message!";
            mymsg.RegisterDeliveryNotification = true; //I want delivery notification for this message

            mmclient.SendMessage(mymsg);
        }

        private void button3_Click(object sender, EventArgs e)
        {
            mmclient.Shutdown();
        }
    }
}

Hm, Ben.. what is here wrong now using this client lib? is there something what our server doen't recognize? Is my code OK ( simple client connecting and sending of a message""Hello, this is my simple client test message!";?
I have no idea... :-(

thank you

regards

Codexer

Coordinator
Sep 17, 2011 at 4:17 AM

Codexer,

As you understand, the SMPP lib offers a bare-bone implementation of the SMPP protocol. To use it in your own implementation, you need to have a good grasp of the SMPP protocol and you need to know

what kind of data to pass on to the server to get your desired response.

That said, if you want to work with DLR messages, you should know what kind of data to return to the server for this to work, and unfortunately, this has nothing to do with the framework implementation so I can't be 

of much help.

The server is throwing errors only because it couldn't find certain information in the PDU that was returned from the client.

The best help I can provide here is showing you how to return custom PDU response to the server. But you need to figure out yourself what actual information to return.

In the below code snippet, I assume that the server sends a DeliverSm pdu which is what you want to process.

 

//Code starts here

private void PduReceivedEventHander(object sender, PduReceivedEventArgs e)
{
   if(e.Request is DeliverSm) //Assume we want to process only DeliverSm pdu's
   {
      DeliverSm req = e.Request as DeliverSm
      //Generate response to return to the server
      DeliverSmResp resp = req.CreateDefaultResponse() as DeliverSmResp; //This will create a DeliverSmResp PDU
      //Specify appropriate parameters that the server expects for this to work with DLR callbacks
      //You may contact your gateway provider for further info regarding above parameters


      //Now that you have set all parameters as required, set e.Response so that our custom response
      //gets sent back to the server instead of the implementation default response
      e.Response = resp; //This ensures our custom response is sent back to the server along with our custom data
   }
   //Other stuff goes here are required
}

//Code ends here

 

Sep 26, 2011 at 1:29 PM

Hi Ben,

Thank you for your answer.

It's something ( some error)  with our server which can not process all (best & great) funktionalities of your lib. if I use ( just to compare) another ( ~ 5 Years old) lib and try to get the DLRs it works. but with your lib it doesn't work.

Please keep in mind that YOUR LIB IS GREAT AND THE BEST lib i know. :-)

Our server does have troubles with proccessing of the DeliverSm ( !!!!) to my client. Of course that my client ( that means your lib) can not response to server. TCPIP trace ( dump) with Wireshark 1.6.2 shows that our server is sending MALFORMED DeliverSm !!!

Here the cut of logs of Wireshark:

434 34.633615    194.111.222.34     172.22.23.44     SMPP  290     SMPP     Deliver_sm[Malformed Packet]
435 34.711636    172.22.23.44         194.111.222.34  SMPP 71       SMPP     Deliver_sm - resp: "Unknown error"

Tja.... what to say Ben...  I have first to check why is the server so "stupid" and can not process simple DeliverSm to my client.

Ben, thank you for your help until now. As far as I can find the error in DeliverSm (and solved this) I'll back to you with hopefully gut news.

 

Thank you Ben

nice day

codexer

 

Sep 27, 2011 at 12:09 PM
Edited Sep 27, 2011 at 12:09 PM

Found it...!!!

Our server is generating a malformed DeliverSm. This DeliverSm is including a Tag 0x3136 with a Lenght of 13350 !!!! Besides that this Tag is redundant, it has a wrong lenght ( whole DeliverSm packet does have lenght: 100)

And of course the great good Ben's lib could ( and it is gut so!) not ignore this DeliverSm-Tag-wrong-lenght. and therefore is no DeliverSmResp sending.

...will try to solve this server problem and let you know, Ben.

thanks

best regards

codexer

Coordinator
Oct 7, 2011 at 3:58 AM

Codexer,

Great to hear that you managed to pinpoint the problem.

Please share with me more results as I would like to know how you proceed.

Ben

Nov 23, 2011 at 7:49 AM

Dear Ben and Codexer,

Sorry I cannot help much on answering some inquiries.

I have another question though.

What is the difference between "AutoReconnectDelay" and "KeepAliveInterval"?

Is it possible to set the session as always connected by lowering the default values below?

//Resume a lost connection after 30 seconds
client.AutoReconnectDelay = 3000;

//Send Enquire Link PDU every 15 seconds
client.KeepAliveInterval = 15000;

Kindly advise...

Many Thanks and Best Regards,

Jojo



                //Resume a lost connection after 30 seconds
                client.AutoReconnectDelay = SMSGW_AutoReconnectDelay; //3000;

                //Send Enquire Link PDU every 15 seconds
                client.KeepAliveInterval = SMSGW_KeepAliveInterval; //15000;
Coordinator
Nov 25, 2011 at 3:40 AM

Jojo,

What do you mean "as always connected"?

The SMPP client stays always connected to the SMSC unless it is explicitly stopped. However, there are times such as during a network failure, the client may loose

connection to the SMSC. In this case the client will attempt to re-establish the lost connection after a period (in milliseconds) as specified in the 'AutoReconnectDelay'.

For instance, if the AutoReconnectDelay is set to 10000, the client will try to reconnect to the SMSC 10 seconds after a lost connection is detected.

 

The 'KeepAliveInternal' is the time internal in which the client sends Enquire Link PDUs to check if a connection is still alive.

Hope that helps,

Ben

Jan 17, 2012 at 8:32 AM

Dear Ben and Codexer,

Thanks for all the help.. :)

However, I need some more favor from you guys..

Based on some sample codes that you have shared, I was able to send SMS from our SMS-Gateway.

And also I was able to receive replies sent back to SMS-Gateway using the client.MessageReceived += client_MessageReceived;

which seems to act as a listener for whatever SMS received by the Gateway for the specified properties.SystemID.

 

I was able to create 2 windows service. One for Sending SMS and another one for receiving SMS from the Gateway.

Sending SMS was great where I was able to read from a database table from time to time and send them accordingly based on records status.

In my Receiving SMS windows service, I was able to write to a text file whatever and whenever I received any SMS from the Gateway.

If I run this alone, I am able to receive 10 or more SMS that was sent to the Gateway in series.

But if I start both (Send & Receive) windows service, the Receiving of SMS becomes inconsistent. Where I only receive a very few SMS out of 10 SMS that was sent to the Gateway in series.

The Sending SMS, however, has no problem.

 

Is there a known issue that running two SmppClient() may conflict each other.

Kindly advise.

 

Many Thanks and Best Regards,

Jojo

 

Jan 27, 2012 at 10:38 AM

Dear Codexer

 I recived ESME_ROK from server but not sms receive at user end. 

Code

mmSubmitSm = new SubmitSm(); 
mmSubmitSm.ServiceType = "CMT";
mmSubmitSm.EsmClass = EsmClass.Default; // leave it default at the moment...           
mmSubmitSm.DestinationAddress.Address = "923213761280"; // 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.Aphanumeric; // known settings           
mmSubmitSm.SourceAddress.Address = "WICC";


mmSubmitSm.SetMessageText("Test message Nr. 3 from Codexer", DataCoding.ASCII);   // message content with coding
mmSubmitSmResp = mmSession.SendPdu(mmSubmitSm) as SubmitSmResp; // send PDU                       

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

what's the problem at my end. when i am sending sms successfully using EasySMPP Lib

Help required

Coordinator
Jan 29, 2012 at 5:53 AM

imran

You posted this same question in another discussion and has been replied to.

Ben

Mar 17, 2015 at 5:12 PM
How to delete sms from smpp server when it is received.
Mar 18, 2015 at 10:54 AM
Please help me in this regard.

i am using jamaa smpp client which sends and receives SMS and i have set thread which executes the code every 10 sec save to the database.
but i am receiving duplicate of single sms untile the sms is expired on the server.
what to do to remove this problem from the system. with following code.

TextMessage msg = e.ShortMessage as TextMessage;
db_Connection.Msavesms(msg.Text;);


thanks cooperation.