Page 1 of 3

Fast sending of message

Posted: Tue Aug 13, 2019 9:36 am
by developerlearn999
Hi, i have used the fast sending approche, but actucllay the messages not sent fast enough as expected, for example :

Code: Select all

private async void FastSend(List<SmsMessage> lSmsMessage)
{
foreach (SmsMessage message in lSmsMessage)
            {
                var pduBuilder = SMS.ForSubmit()
                                .From(message.FromNumber, (AddressTON)byte.Parse(config.AdrTONSource), (AddressNPI)byte.Parse(config.AdrNPISource))
                                .To(message.ToNumber)
                                .Text(message.Text)
                                .Coding(SmppTools.GetEncoding(message.Text))
                                .ExpireIn(TimeSpan.FromMinutes(message.ExpireIn))
                                .AddParameter(0x001D, message.LogID.ToString())
                                .DeliveryReceipt();
                pdus.AddRange(pduBuilder.Create(_client));
            }//foreach 
            SubmitSmResp[] results = await _client.Submit(pdus.ToArray());
}
what my code does :
1. pull every time 200 messages
2. call the FastSend
3. i have a log that i see that 70000 messages were "sent" in 25 minutes (means all was pulled from db and send to FastSend in blocks of 200)
in the code the speed is set to 200/sec ->_client.SendSpeedLimit
4. i see that the last messages were actullay sent after 1hour and 30 minutes.
Question :
1. why is the submit so slow? do i need to change any setting?
2. how can i check the Q in side the inetlab to see how many messages are waiting to be sent?


Thanks for any help

Re: Fast sending of message

Posted: Wed Aug 14, 2019 12:33 pm
by developerlearn999
update :
i set my send speed to 200/sec.
my account on the mobile operator defined as 250/sec.
but still it seems like very slow sending....

Re: Fast sending of message

Posted: Wed Aug 14, 2019 2:47 pm
by alt
Here you can find some tips for performance
https://docs.inetlab.com/smpp/v2/articl ... mance.html

Pay attention how RunTest method is implemented in local test.

For performance monitoring you can use following metrics
https://docs.inetlab.com/smpp/v2/articl ... ml#metrics

Also please try to increase SendSpeedLimit value.

Re: Fast sending of message

Posted: Wed Aug 21, 2019 6:35 am
by developerlearn999
i checked the first link
only the _client.WorkerThreads exist.
i dont see this 2 :
client.ReceiveBufferSize = 32 * 1024 * 1024;
client.SendBufferSize = 32 * 1024 * 1024;

why?

Re: Fast sending of message

Posted: Wed Aug 21, 2019 10:42 am
by developerlearn999
ok i found issue, i am on version 6.2.0, downloaded new one now it's ok.
can you explain how to caluclaute :
client.ReceiveBufferSize = 32 * 1024 * 1024;
client.SendBufferSize = 32 * 1024 * 1024;

i didn't find info about this?

thanks

Re: Fast sending of message

Posted: Wed Aug 21, 2019 11:14 am
by alt
Change receive or send buffer size for the TCP socket

client.ReceiveBufferSize = 32 * 1024 * 1024;
client.SendBufferSize = 32 * 1024 * 1024;

A larger buffer size might delay the recognition of connection difficulties. Consider increasing the buffer size if you are using a high bandwidth, high latency connection (such as a satellite broadband provider.)

This two properties do not increase the performance significantly.

Your performance issue was due to await in foreach loop. You should use Task.WhenAll for batch sending.

Re: Fast sending of message

Posted: Wed Aug 21, 2019 11:33 am
by developerlearn999
Hi
thanks for the reply.
i saw that
client.ReceiveBufferSize = 32 * 1024 * 1024;
client.SendBufferSize = 32 * 1024 * 1024;

was added only from version 2.6.9, but when i try to run a simple code:
SmppClient client = new SmppClient();
client.WorkerThreads = 10;
client.SendBufferSize = 32 * 1024 * 1024;
client.ReceiveBufferSize = 32 * 1024 * 1024;
i get error :
Object reference not set to an instance of an object.'

Re: Fast sending of message

Posted: Wed Aug 21, 2019 11:34 am
by alt
thank you. I check this issue.

Re: Fast sending of message

Posted: Sun Aug 25, 2019 2:52 pm
by developerlearn999
how to use : Task.WhenAll ?
currently i am doing the
SubmitSmResp[] results = await _client.Submit(pdus.ToArray());
after the loop ends to add number to the pdus (in the exmaple i copied not correctly.

Re: Fast sending of message

Posted: Sun Aug 25, 2019 3:41 pm
by alt
You can create all SubmitSm PDUs from lSmsMessage list and then submit it with one command:

Code: Select all

SubmitSmResp[] results = await _client.Submit(pdus);
or you can create a list of submit tasks:

Code: Select all

private async Task<IEnumerable<SubmitSmResp>> FastSend(List<SmsMessage> lSmsMessage)
{
         Task<SubmitSmResp> tasks = new Task<SubmitSmResp>();

            foreach (SmsMessage message in lSmsMessage)
            {
                var pduBuilder = SMS.ForSubmit()
                                .From(message.FromNumber, (AddressTON)byte.Parse(config.AdrTONSource), (AddressNPI)byte.Parse(config.AdrNPISource))
                                .To(message.ToNumber)
                                .Text(message.Text)
                                .Coding(SmppTools.GetEncoding(message.Text))
                                .ExpireIn(TimeSpan.FromMinutes(message.ExpireIn))
                                .AddParameter(0x001D, message.LogID.ToString())
                                .DeliveryReceipt();

               tasks.Add(_client.Submit(pduBuilder));
            }//foreach 

           await Task.WhenAll(tasks);

          return tasks.Select(x => x.Result);
}

Re: Fast sending of message

Posted: Sun Sep 01, 2019 11:33 am
by developerlearn999
Hi
i already di

Code: Select all

SubmitSmResp[] results = await _client.Submit(pdus);
but i can't get over the limit of 100/sec

Re: Fast sending of message

Posted: Wed Sep 04, 2019 6:55 am
by developerlearn999
alt - can you explain how you decide how many messages per second to send to the server?

Re: Fast sending of message

Posted: Wed Sep 04, 2019 6:57 am
by alt
I'm checking this issue right now. There is something wrong. I'm going to fix it in the next version.

Re: Fast sending of message

Posted: Thu Sep 05, 2019 9:02 am
by developerlearn999
Hi alt, another issue :
when doing
SubmitSmResp[] results = await _client.Submit(pdus.ToArray());
and you get disconnected in the middle,, the code is stuck on that line and not getting passs it.
is this a bug?
what i did i sent 50 messages, and dissconnected after 10 (which were delivered), but the rest are stuck event after connection is back!
and the code i stuck on that line.

more then thay, i set the ResponseTimeout to TimeSpan.FromSeconds(5).
then in the middle i disconnected the cable, and then i passed the above line of code.
then i do it again, and it's stuck again! something not stable here.

Re: Fast sending of message

Posted: Thu Sep 05, 2019 9:25 pm
by alt
please test both issues with the version 2.7.0-beta-190905
from NuGet https://www.nuget.org/packages/Inetlab. ... eta-190905
or in https://account.inetlab.com