SubmitAsync data.Response.Status

.NET library for SMPP protocol
Locked
Kernighan
Posts: 3
Joined: Fri Jun 12, 2015 9:17 am

SubmitAsync data.Response.Status

Post by Kernighan » Fri Jun 12, 2015 9:27 am

First, thanks for amazing library, I bought source code licence.

I have the following issue: When i get message on SmppServerOnEvClientSubmitSm and make smppClient.Submit(data) i can response back to the client who sends me the message
data.Response.Status = response.Status; or other status which i want.

Can I make the same thing with SubmitAsync?
alt
Site Admin
Posts: 985
Joined: Tue Apr 25, 2006 9:45 am

Re: SubmitAsync data.Response.Status

Post by alt » Fri Jun 12, 2015 4:24 pm

Hello Kernighan,

As far as I understood you are forwarding SubmitSm PDU, received by your server, to another server.
I suggest to use store and forward way. It means you receive this PDU, store it and send OK response with your own MessageId and then send same PDU further to another server with another sequence_number. Response status ESME_ROK means that only remote side has received a PDU. There is a delivery receipt that tells if a mobile phone has received a message.
Kernighan
Posts: 3
Joined: Fri Jun 12, 2015 9:17 am

Re: SubmitAsync data.Response.Status

Post by Kernighan » Tue Jun 16, 2015 1:01 pm

For example i wrote the following code:

Code: Select all

 private static void SmppServer_evClientSubmitSm(object sender, SmppServerClient client, SubmitSm data)
  {
   try
   {
    Task.Factory.StartNew(() =>
     {
      if (data.RegisteredDelivery != 0)
      {
       var deliver = client.Deliver(SMS.ForDeliver().From(data.SourceAddr, data.SourceAddrTon, data.SourceAddrNpi).To(data.DestAddr, data.DestAddrTon, data.DestAddrNpi).Coding(data.DataCoding).Receipt(new Receipt
        {
         Text = data.MessageText,
         State = MessageState.Accepted,
         DoneDate = DateTime.Now,
         MessageId = data.Response.MessageId,
         SubmitDate = DateTime.Now,
        }));

       foreach (var deliverSmResp in deliver)
       {
        data.Response.Status = deliverSmResp.Status;
       }
      }
     });
   }
   catch (Exception ex)
   {
    data.Response.Status = CommandStatus.ESME_RSYSERR;

#if DEBUG
    Console.WriteLine("SMPP SERVER CLIENT SUBMIT SM EXCEPTION: {0} {1} {2}", ex.Message, ex.StackTrace, Environment.NewLine);
#endif
    Log.Error("SMPP SERVER CLIENT SUBMIT SM EXCEPTION", ex);
   }
  }
First, i call deliver in task as you see because i need fast processing e.t.c.
In this case if i create the thread, i can't return deliver response status.
Exists some solution to return status back to the client which i get after i call deliver method.
alt
Site Admin
Posts: 985
Joined: Tue Apr 25, 2006 9:45 am

Re: SubmitAsync data.Response.Status

Post by alt » Wed Jun 17, 2015 4:53 pm

It seems a bit strange that you send DLR back as soon as you receive SubmitSm from client. Do you send received SubmitSm to the next server?
When it is so, it is possible that you are going to send second DLR to the client, when that server will send you real DLR.

Anyway you need to send at first SubmitSmResp with your own message id and only then corresponding DLR that contains same message id.

But I agree that there is a need that sometimes you need to suppress automatic responses and send SubmitSmResp later manually. I'll try to add this feature.
Locked