event "evDeliver​Sm" not working

.NET library for SMPP protocol
Locked
hus007
Posts: 3
Joined: Sun Apr 10, 2011 1:52 am

event "evDeliver​Sm" not working

Post by hus007 » Sun Apr 10, 2011 2:19 am

Hello,

I need a help, I'm trying to redrive the data for sent sms using Inetlab.SMPP to be sure the message has been delivered.

i read in the website that the event evDeliverSm should be fired, but unfortunately its not fired when i send SMS.

can you help me please.

i add the below in my code:


AddHandler client.evDeliverSm, AddressOf client_evDeliverSm

sm.RegisteredDelivery = 1

Private Sub client_evDeliverSm(ByVal sender As Object, ByVal data As Inetlab.SMPP.PDU.DeliverSm)
do check for the deliveray report......
end sub
alt
Site Admin
Posts: 918
Joined: Tue Apr 25, 2006 9:45 am

Re: event "evDeliver​Sm" not working

Post by alt » Mon Apr 11, 2011 8:07 am

Please make sure that you bound in Transceiver mode and SMPP server supports delivery receipt.
Also attach to the event evDataSm. Sometimes SMSC sends delivery receipt in DataSm message instead of DeliverSm.
hus007
Posts: 3
Joined: Sun Apr 10, 2011 1:52 am

Re: event "evDeliver​Sm" not working

Post by hus007 » Wed Apr 20, 2011 6:18 pm

i check the bound and its for Transceiver mode and SMPP server are supports delivery receipt. but still now not working , the event AddHandler client.evDeliverSm, AddressOf client_evDeliverSm are not fired and
even the event AddHandler client.evDataSm, AddressOf client_evDataSm are not fired too !!!!
below is my code:
Imports Inetlab.SMPP
Public Class clsSendSMS
Private client As Inetlab.SMPP.SmppClient

Public Sub New()
client = New Inetlab.SMPP.SmppClient()
client.Timeout = 60000
client.NeedEnquireLink = True
AddHandler client.evDeliverSm, AddressOf client_evDeliverSm
AddHandler client.evDataSm, AddressOf client_evDataSm
End Sub

Sub Main(ByVal sReturnValue As clsSMS)
Try
Connect()
If client.Status = Inetlab.SMPP.Common.ConnectionStatus.Open Then
Bind()
End If
Dim sMsgbox As String = sReturnValue.Message
Dim sNumber As String = sReturnValue.Telephone
If sNumber.Trim <> "" And sMsgbox.Trim <> "" Then
Dim sValue As String = sendSMS(sNumber, sMsgbox, sReturnValue)
If sValue.Trim = "SEND" Then
sReturnValue.DeliverableStatus = "S"
sReturnValue.WS_Error_ID = "0"
sReturnValue.WS_Error_MSG = ""
End If
End If
Disconnect()
Catch ex As Exception
sReturnValue.WS_Error_ID = "-5"
sReturnValue.WS_Error_MSG = sReturnValue.WS_Error_MSG & Environment.NewLine & ex.Message.Replace("Inetlab.", "HAAD.") & Environment.NewLine & sError
Err.Clear()
End Try
End Sub

Private Function sendSMS(ByVal sNumber As String, ByVal sMsgbox As String, ByVal sReturnValue As clsSMS) As String
Dim sValue As String = ""
Try
Dim coding As Inetlab.SMPP.Common.DataCodings = Common.DataCodings.UCS2 ' GetDataCoding()
Dim mode As Inetlab.SMPP.Common.SubmitMode = Common.SubmitMode.ShortMessage ' GetSubmitMode()
If client.Status <> Inetlab.SMPP.Common.ConnectionStatus.Bound Then
sReturnValue.WS_Error_ID = "-3"
sReturnValue.WS_Error_MSG = "Error : Before sending messages, please connect to SMSC." & Inetlab.SMPP.Common.ConnectionStatus.Bound
sValue = "Error : Before sending messages, please connect to SMSC."
'Return sValue
End If

Dim req As List(Of Inetlab.SMPP.PDU.SubmitSm) = client.PrepareSubmit(mode, Byte.Parse(0), Byte.Parse(0), 1111, Byte.Parse(1), Byte.Parse(1), _
sNumber, coding, sMsgbox)

For Each sm As Inetlab.SMPP.PDU.SubmitSm In req
sm.RegisteredDelivery = 1
sm.SMSCReceipt = Common.SMSCDeliveryReceipt.SuccessFailure
sm.ValidityPeriod = DateTime.Now.AddDays(2).ToString("yyMMddhhmmss000+")
Next

Dim resp As List(Of Inetlab.SMPP.PDU.SubmitSmResp) = client.Submit(req)

If resp.Count > 0 AndAlso resp(0).Status = Inetlab.SMPP.Common.CommandStatus.ESME_ROK Then
'Console.Write("QuerySm for message " + resp(0).MessageId)
Dim qresp As Inetlab.SMPP.PDU.QuerySmResp = client.Query(resp(0).MessageId, Byte.Parse(0), Byte.Parse(0), "1111")
'Dim dresp As Inetlab.SMPP.PDU.DataSm = req(0).SMSCReceipt.
sReturnValue.Message_ID = resp(0).MessageId
sValue = "SEND"
End If
Catch ex As Exception
sError = "0 - " & sReturnValue.WS_Error_MSG & Environment.NewLine & ex.Message
End Try

Return sValue
End Function
Private Sub client_evDataSm(ByVal sender As Object, ByVal data As Inetlab.SMPP.PDU.DataSm)
Dim messageText As String = data.Client.GetMessageText(data.UserDataPdu.ShortMessage, data.DataCoding)
End Sub

Private Sub Connect()
Try
If client.Status = Inetlab.SMPP.Common.ConnectionStatus.Closed Then
client.AddrNpi = Convert.ToByte(0)
client.AddrTon = Convert.ToByte(0)
client.SystemType = "EXT_SME"
client.Connect("111.111.111.111", Convert.ToInt32(111), False)
End If
Catch ex As Exception
sError = "0 - " & ex.Message
End Try
End Sub

Private Sub Bind()
Try
Dim btrp As Inetlab.SMPP.PDU.BindResp = client.Bind("UserID", "Password", Inetlab.SMPP.Common.ConnectionMode.Transceiver)
Select Case btrp.Status
Case Inetlab.SMPP.Common.CommandStatus.ESME_ROK
Exit Select
Case Else
Disconnect()
Exit Select
End Select
Catch ex As Exception
sError = sError & "1 - " & ex.Message
End Try
End Sub

Private Sub UnBind()
Dim ubtrp As Inetlab.SMPP.PDU.UnBindResp = client.UnBind()

Select Case ubtrp.Status
Case Inetlab.SMPP.Common.CommandStatus.ESME_ROK
Exit Select
Case Else
client.Disconnect()
Exit Select
End Select

End Sub
End Class
hus007
Posts: 3
Joined: Sun Apr 10, 2011 1:52 am

Re: event "evDeliver​Sm" not working

Post by hus007 » Wed Apr 20, 2011 6:21 pm

i forget to copy the event

Private Sub client_evDeliverSm(ByVal sender As Object, ByVal data As Inetlab.SMPP.PDU.DeliverSm)
If data.SegmentNumber > 0 Then

AddMessageSegmentToCollector(data)

Dim messageText As String = data.Client.GetMessageText(data.UserDataPdu.ShortMessage, data.DataCoding)

AddToLog("DeliverSm part received : " + " Sequence : " + data.Sequence.ToString() + " SourceAddr : " + data.SourceAddr + " Segments ( Number: " + data.SegmentNumber.ToString() + ", Total : " + data.TotalSegments.ToString() + ", Reference : " + data.MessageReferenceNumber.ToString() + " ) Coding : " + data.DataCoding.ToString() + " MessageText : " + messageText)


If IsLastSegment(data) Then

Dim fullMessage As String = RetrieveFullMessage(data)

AddToLog("Full message: " + fullMessage)

End If
Else
Dim messageText As String = data.Client.GetMessageText(data.UserDataPdu.ShortMessage, data.DataCoding)


AddToLog("DeliverSm received : " + " Sequence : " + data.Sequence.ToString() + " SourceAddr : " + data.SourceAddr + " Coding : " + data.DataCoding.ToString() + " MessageText : " + messageText)
End If

' Here you can change DeliverSmResp status
' data.Response.Status = CommandStatus.ESME_RINVCMDID;
End Sub


and still not working !!!! please advice
alt
Site Admin
Posts: 918
Joined: Tue Apr 25, 2006 9:45 am

Re: event "evDeliver​Sm" not working

Post by alt » Fri Apr 22, 2011 9:58 am

You need to remove
sm.SMSCReceipt = Common.SMSCDeliveryReceipt.SuccessFailure

Are you able to receive SMS from mobile phone in your application?

We need to make sure that server sends Delivery Receipt to client.
On client side you can catch event evReceiveData to see what byte arrays client receive from server
and if you will see command_id sequence 0x00000005 after 4 byte of the packet length then client received DeliverSm.
tomasz.dobrowolski
Posts: 2
Joined: Mon Mar 10, 2014 10:15 am

Re: event "evDeliver​Sm" not working

Post by tomasz.dobrowolski » Mon Mar 10, 2014 10:20 am

I have the same problem. My sms gate suports delivery reports. After sending sms, i cant see new message(delivery report) in gate queene.
But DeliverSmEventHandler, and DataSmEventHandler doesnt fire up!

Code: Select all

public static void Delivered(object sender, DeliverSm data)
        {
            DeliverSm x = data;
        }
        public static void client_evDataSm(object sender, DataSm data)
        {
            DataSm x = data;
        }
        public static void SendSMS()
        {

            




            SmppClient client = new SmppClient();
            client.evDeliverSm += new DeliverSmEventHandler(Delivered);
            client.evDataSm +=new DataSmEventHandler(client_evDataSm);
            client.ev


           client.Connect("*",2775);
           
            if (client.Status == Inetlab.SMPP.Common.ConnectionStatus.Open)
            {
                client.Bind("*", "*", Inetlab.SMPP.Common.ConnectionMode.Transmitter);

                if (client.Status == Inetlab.SMPP.Common.ConnectionStatus.Bound)
                {
                    

                    IList<SubmitSmResp> respList = null;
                    
                    
                    IList<SubmitSmResp> respList1 = client.Submit(
                       SMS.ForSubmit().From("xxx").To("xxx").Text("Test SMS").Coding(DataCodings.UCS2).DeliveryReceipt()
                       );
                
                    
                  

                    client.UnBind();
                }

                client.Disconnect();
            }
        }

Where is my mistake?
PS: i bougth developer license for SMPP
tomasz.dobrowolski
Posts: 2
Joined: Mon Mar 10, 2014 10:15 am

Re: event "evDeliver​Sm" not working

Post by tomasz.dobrowolski » Mon Mar 10, 2014 10:38 am

Ok, i see my fault: i choose connection mode Transmitter...

hehe
Locked