0

I use Inetlab.SMPP 2.8.1 (by licence reason) to implement an SMPP gateway. SMS message with long text must be split into small parts. Therefore I follow the article and use a MessageComposer instance to combine concatenated messages:

private void OnClientSubmitSm(object sender, SmppServerClient client, SubmitSm pdu)
{
    _composer.AddMessage(pdu);
    if (_composer.IsLastSegment(pdu))
    {
        string fullMessage = _composer.GetFullMessage(pdu);
        // do something
    }
}

where _composer is a MessageComposer.

But the code produces the following error:

System.ArgumentNullException: Value cannot be null. (Parameter 'key')
at System.Collections.Concurrent.ConcurrentDictionary`2.ThrowKeyNullException()
at System.Collections.Concurrent.ConcurrentDictionary`2.TryGetValue(TKey key, TValue& value)
at Inetlab.SMPP.Common.DefaultComposerItemStore.TryGet(String key, ComposerItem& item)
at Inetlab.SMPP.Common.MessageComposer.IsLastSegment[TSmppMessage](TSmppMessage message)

Note, the similar code works well for evDeliverSm event. But it doesn't want to handle incoming submit_sm PDUs.

What I do wrong? And what do I must to do to get expected result?

Alexander
  • 4,420
  • 7
  • 27
  • 42

1 Answers1

1

The problem has been solved using evFullMessageReceived event instead of checking message segments. So the following event handlers process incoming SUBMIT_SM PDU as expected:

// the method handles evClientSubmitSm event of SmppServer instance
private void OnClientSubmitSm(object sender, SmppServerClient client, SubmitSm pdu)
{
    try
    {
        _composer.AddMessage(pdu);
    }
    catch (Exception error)
    {
        pdu.Response.Header.Status = CommandStatus.ESME_RSUBMITFAIL;
        // log error
    }
}

// the method handles evFullMessageReceived event of MessageComposer instance
private void OnFullMessageReceived(object sender, MessageEventHandlerArgs arguments)
{
    SubmitSm pdu = null;
    SmppClientBase client = null;

    try
    {
        pdu = arguments.GetFirst<SubmitSm>();
        client = pdu.Client;
        string fullMessage = arguments.Text;
        // save message
    }
    catch (Exception error)
    {
        pdu.Response.Header.Status = CommandStatus.ESME_RSUBMITFAIL;
        // log error
    }
}

// the method handles evFullMessageTimeout event of MessageComposer instance
private void OnFullMessageTimeout(object sender, MessageEventHandlerArgs arguments)
{
    SubmitSm pdu = arguments.GetFirst<SubmitSm>();
    // log warning
}
Alexander
  • 4,420
  • 7
  • 27
  • 42