Construct delivery receipt for connected client

.NET library for SMPP protocol
Post Reply
jimbo
Posts: 1
Joined: Thu Oct 24, 2019 10:55 am

Construct delivery receipt for connected client

Post by jimbo » Thu Oct 24, 2019 11:11 am

Hi

Im using Inetlab SMPP to forward SMPP messages to an HTTP service. The HTTP service sends an unstructured delivery receipt response which I need to convert into a valid SMPP delivery receipt and send to the connected client, however, I cant find documentation on how to construct a delivery receipt for sending to client. From various information I have gathered, I created the code below:

Code: Select all

                
                var dlrs = sms.Select(d => new DeliverSm
                {
                    
                    Header = new SmppHeader(CommandSet.DeliverSm) {Status = CommandStatus.ESME_ROK},
                    DestinationAddress = new SmeAddress(d.Recipient, AddressTON.International, AddressNPI.Unknown),
                    Receipt = new Receipt
                    {
                        Delivered = d.Message.CountedParts,
                        DoneDate = d.Delivered,
                        ErrorCode = d.ErrorCode,
                        SubmitDate = d.Submitted,
                        MessageId = d.Message.MessageId,
                        State = MessageState.Delivered,
                        Text = d.Message.Body,
                        Submitted = d.Message.CountedParts
                    }
                });

                var response = client.Deliver(dlrs.ToArray()).Result;
  
However, I get the following error:

Code: Select all

System.AggregateException: One or more errors occurred. ---> System.ArgumentNullException: Value cannot be null.
Parameter name: String
   at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
   at System.Number.ParseUInt32(String value, NumberStyles options, NumberFormatInfo numfmt)
   at System.UInt16.Parse(String s, NumberStyles style, NumberFormatInfo info)
   at System.UInt16.Parse(String s)
   at Inetlab.SMPP.Parameters.NetworkErrorCodeParameter.???
??????(Object )
   at Inetlab.SMPP.Parameters.NetworkErrorCodeParameter..ctor(Byte networkType, String errorCode)
   at Inetlab.SMPP.Parameters.NetworkErrorCodeParameter.GSM(String errorCode)
   at Inetlab.SMPP.Common.SmppWriter.???
??????(Object )
   at Inetlab.SMPP.Common.SmppWriter.Write(DeliverSm pdu)
   at Inetlab.SMPP.Common.SmppWriter.WritePDU(SmppPDU pdu)
   at Inetlab.SMPP.SmppClientBase.???
??????.???
?????(Object , Object )
   at Inetlab.SMPP.SmppClientBase.???
??????.???
??????()
   at System.Threading.Tasks.Task.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult()
   at Inetlab.SMPP.SmppClientBase.<SendRequestAsync>d__89`2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at Inetlab.SMPP.SmppServerClient.<Deliver>d__51.MoveNext()
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
   at System.Threading.Tasks.Task`1.get_Result()
   at SMPPtoHTTP.Program.ShareDeliveryReports(SmppServerClient client)
---> (Inner Exception #0) System.ArgumentNullException: Value cannot be null.
Parameter name: String
   at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
   at System.Number.ParseUInt32(String value, NumberStyles options, NumberFormatInfo numfmt)
   at System.UInt16.Parse(String s, NumberStyles style, NumberFormatInfo info)
   at System.UInt16.Parse(String s)
   at Inetlab.SMPP.Parameters.NetworkErrorCodeParameter.???
??????(Object )
   at Inetlab.SMPP.Parameters.NetworkErrorCodeParameter..ctor(Byte networkType, String errorCode)
   at Inetlab.SMPP.Parameters.NetworkErrorCodeParameter.GSM(String errorCode)
   at Inetlab.SMPP.Common.SmppWriter.???
??????(Object )
   at Inetlab.SMPP.Common.SmppWriter.Write(DeliverSm pdu)
   at Inetlab.SMPP.Common.SmppWriter.WritePDU(SmppPDU pdu)
   at Inetlab.SMPP.SmppClientBase.???
??????.???
?????(Object , Object )
   at Inetlab.SMPP.SmppClientBase.???
??????.???
??????()
   at System.Threading.Tasks.Task.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult()
   at Inetlab.SMPP.SmppClientBase.<SendRequestAsync>d__89`2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at Inetlab.SMPP.SmppServerClient.<Deliver>d__51.MoveNext()<---
Please advise if my construction of the delivery receipts is correct?
alt
Site Admin
Posts: 854
Joined: Tue Apr 25, 2006 9:45 am

Re: Construct delivery receipt for connected client

Post by alt » Fri Oct 25, 2019 11:35 am

What value have you set for property Receipt.ErrorCode ?
alt
Site Admin
Posts: 854
Joined: Tue Apr 25, 2006 9:45 am

Re: Construct delivery receipt for connected client

Post by alt » Fri Oct 25, 2019 11:49 am

In SMPP Protocol Specification v3.4 you can find:

Appendix B
Field: err
Size (octets): 3
Type: C-Octet Fixed Length String
Description: Where appropriate this may hold a Network specific error code or an SMSC error code for the attempted delivery of the message. These errors are Network or SMSC specific and are not included here.

TLV Parameter:

5.3.2.31 network_error_code
The network_error_code parameter is used to indicate the actual network error code for a
delivery failure. The network error code is technology specific.

Field: Value
Size (octets):3
Type: Octet String
Description:

Code: Select all

Sub-field		Size 		Type
Network Type		1 		Integer
Error Code 		2 		Integer
The first octet indicates the network type.

The following values are defined:
1 = ANSI-136
2 = IS-95
3 = GSM
4 = Reserved
All other values reserved.

The remaining two octets specify the actual
network error code appropriate to the
network type.
Post Reply