Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Concatenated Messages get merged when using BeginSendMessage, and UCS2 encoding. #39

Open
MahmoodRasooli opened this issue Aug 27, 2020 · 5 comments

Comments

@MahmoodRasooli
Copy link

MahmoodRasooli commented Aug 27, 2020

Hi Adham,
I've been using JamaaSmpp for the past nine months and lately, we've encountered a very abnormal problem. When sending large messages(more than 2 PDUs) asynchronously using BeginSendMessage, sometimes the messages get merged and the user gets only one message which is a combination of the two sent messages. The final message has the exact number of characters of one of the messages but the content is neither one of them.
P.S: It's worth mentioning that I send nearly 500 PDUs every second in rush hours.
I appreciate it if you can help me with this issue. Many thanks.

@MahmoodRasooli
Copy link
Author

MahmoodRasooli commented Aug 28, 2020

Found the problem. It was because of the SegmentId in UDH. The framework generates this number randomly, and that sometimes causes this issue, because it generates a single number every time, hence the different messages get the same SegID.

TextMessage.cs line 83:
var SegID = new Random().Next(1000, 9999); // create random SegmentID

@AdhamAwadhi

@AdhamAwadhi
Copy link
Owner

AdhamAwadhi commented Sep 1, 2020

Smpp protocol give you only 1 byte as message identification.
https://smpp.io/concatenated-messages/

If you have any solution give us a hint.

Thank you

@MahmoodRasooli
Copy link
Author

MahmoodRasooli commented Sep 12, 2020

Firstly, you did an outstanding job creating this library, well done, and my compliments to you.
Secondly, you're right, the message identification only allows 1 byte, however, I think there's a better way than generating a random number.
I used a [Thread Static] variable to use it as SegId([Thread Static] because I need to use multiple Transceiver connections in my application, hence multiple SmppClient objects). Then I add it incrementally and if it gets bigger than FF, I'll reset it to 0. This way there's a better chance to at least reduce the possibility of encountering conflicts while sending messages with high speed.

I also have a question to ask you, what do you think is the best way to use your library to be able to send more than 600-700 PDUs per second? As you know, Thread.Sleep() and other workarounds like this are not acceptable.

Thanks for your time.
@AdhamAwadhi

@AdhamAwadhi
Copy link
Owner

I'm not the creator of this library. See readme. I liked it and I just maintain it as possible as I can . (Working full Time)

Thank you for sharing your solution. Is your application a multi-threaded technology like Web applications?

About your question: why you need something like Thread.Sleep()?

And sorry for my late response. I'm working full time as I mentioned before

@MahmoodRasooli
Copy link
Author

Yes, the application which I’ve developed is a multi-threaded windows service(a daemon in linux).
About the Thread.Sleep(Task.Delay), the SMSC that my company is working with, limited the number of tcp connections which we can use(10 in total), and each connection has a specific TPS. So I need to adjust the application’s send rate with that throughput, otherwise I’ll get Smpp_Throttling error.
I appreciate it if you can share any other solutions if you’ve ever came across one.

Also thanks for the response, I’m a full-time developer too and I know the limitations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants