Fast sending of message

developerlearn999
Posts: 85
Joined: Thu Jun 20, 2019 9:34 am

Fast sending of message

Post by developerlearn999 » Tue Aug 13, 2019 9:36 am

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
Last edited by developerlearn999 on Sun Aug 25, 2019 2:52 pm, edited 1 time in total.
developerlearn999
Posts: 85
Joined: Thu Jun 20, 2019 9:34 am

Re: Fast sending of message

Post by developerlearn999 » Wed Aug 14, 2019 12:33 pm

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....
alt
Site Admin
Posts: 985
Joined: Tue Apr 25, 2006 9:45 am

Re: Fast sending of message

Post by alt » Wed Aug 14, 2019 2:47 pm

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.
developerlearn999
Posts: 85
Joined: Thu Jun 20, 2019 9:34 am

Re: Fast sending of message

Post by developerlearn999 » Wed Aug 21, 2019 6:35 am

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?
developerlearn999
Posts: 85
Joined: Thu Jun 20, 2019 9:34 am

Re: Fast sending of message

Post by developerlearn999 » Wed Aug 21, 2019 10:42 am

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
alt
Site Admin
Posts: 985
Joined: Tue Apr 25, 2006 9:45 am

Re: Fast sending of message

Post by alt » Wed Aug 21, 2019 11:14 am

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.
developerlearn999
Posts: 85
Joined: Thu Jun 20, 2019 9:34 am

Re: Fast sending of message

Post by developerlearn999 » Wed Aug 21, 2019 11:33 am

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.'
alt
Site Admin
Posts: 985
Joined: Tue Apr 25, 2006 9:45 am

Re: Fast sending of message

Post by alt » Wed Aug 21, 2019 11:34 am

thank you. I check this issue.
developerlearn999
Posts: 85
Joined: Thu Jun 20, 2019 9:34 am

Re: Fast sending of message

Post by developerlearn999 » Sun Aug 25, 2019 2:52 pm

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.
alt
Site Admin
Posts: 985
Joined: Tue Apr 25, 2006 9:45 am

Re: Fast sending of message

Post by alt » Sun Aug 25, 2019 3:41 pm

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);
}
developerlearn999
Posts: 85
Joined: Thu Jun 20, 2019 9:34 am

Re: Fast sending of message

Post by developerlearn999 » Sun Sep 01, 2019 11:33 am

Hi
i already di

Code: Select all

SubmitSmResp[] results = await _client.Submit(pdus);
but i can't get over the limit of 100/sec
developerlearn999
Posts: 85
Joined: Thu Jun 20, 2019 9:34 am

Re: Fast sending of message

Post by developerlearn999 » Wed Sep 04, 2019 6:55 am

alt - can you explain how you decide how many messages per second to send to the server?
alt
Site Admin
Posts: 985
Joined: Tue Apr 25, 2006 9:45 am

Re: Fast sending of message

Post by alt » Wed Sep 04, 2019 6:57 am

I'm checking this issue right now. There is something wrong. I'm going to fix it in the next version.
developerlearn999
Posts: 85
Joined: Thu Jun 20, 2019 9:34 am

Re: Fast sending of message

Post by developerlearn999 » Thu Sep 05, 2019 9:02 am

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.
alt
Site Admin
Posts: 985
Joined: Tue Apr 25, 2006 9:45 am

Re: Fast sending of message

Post by alt » Thu Sep 05, 2019 9:25 pm

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
Post Reply