(Kannel) No foreign message ID when sending concatenated messages - sms

I am trying to send multipart (concatenated) messages using Kannel.
Currently, Kannel is configured to call a dlr url (which is a PHP script) that does some stuff with the delivery report.
When sending single message (ie a message that has 10 characters), it does get delivered to my mobile phone and Kannel calls the dlr url twice, both times returning the foreign message ID - both when the dlr status code was 8, which means that it was accepted by SMSC, and when the dlr status code was 1, which means the message was delivered (as it really was).
Now, that works all great but when I try to send a multipart message (ie a message that has 250 characters), it again gets delivered to my phone as one message (as I set the concatenation parameter to true), but when Kannel called that dlr url when status code was 8 (accepted by SMSC) - it didn't provide any foreign message id, as it would normally in the previous example with message of 10 characters.
I could see in the logs that Kannel indeed received two foreign message ID's from the SMSC (ie 123 and 124), but when calling the dlr url on status code 8 (accepted by SMSC) Kannel never provided those IDs so the field in the database I use to store these IDs has been set from NULL to an empty string.
What is really confusing is that once the multi-part message got delivered to my phone, Kannel called that dlr url again with status code of 1 (delivered) and it passed the foreign message id of the first message, which is what I want to be passed on any status code.
So my question is - how can I make Kannel use that foreign message id when calling the dlr url when status code is 8 (accepted by SMSC)? It works when status code is 1 (delivered) but not when status code is 8.
Note: I am using Kannel 1.4.4 but I am willing to upgrade if there's a newer version with this feature included.

Related

Trying to process a message received in Bytes using google Protobuf, but sometimes getting "Protocol message end-group tag did not match expected tag"

We are processing messages received from a Queue, which is in byte[]. And processing them using google Protobuf-java-2.6.1.jar calling mergeFrom of the com.google.protobuf.AbstractMessage, which in turn is calling com.google.protobuf.CodedInputStream.
Sometimes, the messages are successfully processed, but sometimes throwing InvalidProtocolBufferException.invalidTag().
I understand that "Groups in protobuf are written as a start/end numeric pair", But as we are receiving the messages in byte[], how can we make sure what are the start and end tags and which end group tag not matched with what expected Tag?
Sometimes, the same message get processed successfully on a local windows machine, but the same message fails on a Linux box.
Message.Builder builder = getMessageBuilder(messageType);
ExtensionRegistry registry = ExtensionRegistry.newInstance();
Message parsedMessage = builder.mergeFrom(message, registry).build();`
message is a byte[].
The 3rd line is throwing the exception.

How to Set Message ID via MQJavaClient

I am trying to set custom string as Message ID via MQJavaClient what I have done so for is below:
String I want to place in message id
example :92f5fd96300e8dce
Get hex number from online[codebeautify.org]
example:39326635666439363330306538646365
In Java client code as below
String str = "39326635666439363330306538646365";
sendmsg.messageId = str.getBytes();
When try to print messageid, it is giving some other results
sendmsg.messageId : [B#1b40d5f0
Still needed messageid is not populated with MQ Message.
Please help on this to set custom message ID for MQ Message.
Roger / Josh 26 dec 2017
Need help on this
If you need/want to store your own message id or transaction id then use a message property or the Correlation ID field of the MQMD - just don't use the MQMD's Message ID.
In our application , we are using both msgid/txnid and correlation id.
msgid/txnid will different for each transaction(should be same for request an response).
correlation id will same across all transactions.
What am trying now?
1.System A and System B talking via MQs
2.Now suddenly System B is responding with different format as response and System A is not able perform its operations.
3.Now my job is to simulate System B response via java client.
4.I found in our application we use both msgid and correl id
5.I am done with correl id and its reading perfectly by System A.
6.But this msgid is NOT populating via java client and showing as msgid as null in logs.
Bad idea, very bad idea to generate your own Message ID in IBM MQ. MQ will automatically generate a unique Message ID for the message when your application issues an MQPUT and/or MQPUT1.
If you need/want to store your own message id or transaction id then use a message property or the Correlation ID field of the MQMD - just don't use the MQMD's Message ID.

Get unread message via rest api for Rocket.chat

I'm trying to get the numbers of direct unread messages in rocket.chat.
I'm on 0.53.0 and trying with /api/v1/im.history to get the numbers of unreads. If I set unreads to "true" I can't distinguish between read and unread.
What is the way to get the numbers of unread?
When calling the /api/v1/im.history if you set unreads to true you should have 3 properties on the object returned:
messages
firstUnread
unreadNotLoaded
This will be the first message unread. You would need to then find all messages with a newer timestamp and that would be your unread messages.
Reference to the code generating this payload: https://github.com/RocketChat/Rocket.Chat/blob/0.53.0/packages/rocketchat-lib/server/methods/getChannelHistory.js#L72

Implementing bulk-messaging from Salesforce to/from Twilio, hitting Salesforce API limits

I am building an integration between Salesforce and Twilio that sends/receives SMS using TwilioForce REST API. The main issue is getting around the 10-call API limit from Salesforce, as well as the prohibition on HTTP call outs from a trigger.
I am basing the design on Dan Appleman's Asynchronous Request processes, but in either Batch mode or RequestAsync(), ASync(), Sync(), repeat... I'm still hitting the limits.
I'd like to know how other developers have done this successfully; the integrations have been there for a while, but the examples are few and far between.
Are you sending unique messages for each record that has been updated? If not, then why not send one message to multiple recipients to save on your API limits?
Unfortunately, if you do actually need to send more than 10 unique messages there is no way to send messages in bulk with the Twilio API, you could instead write a simple application that runs on Heroku or some other application platform that you can call out to that will handle the SMS functionality for you.
I have it working now using the following structure (I apologize for the formatting - it's mostly pseudocode):
ASyncRequest object:
AsyncType (picklist: 'SMS to Twilio' is it for now),
Params (long text area: comma-separated list of Ids)
Message object:
To (phone), From (phone), Message (text), Sent (boolean), smsId (string), Error (text)
Message trigger: passes trigger details to CreateAsyncRequests() method.
CreateAsyncRequests: evaluate each new/updated Message__c; if Sent == false for any messages, we create an AsyncRequest, type=SMS to Twilio, Params += ',' + message.Id.
// Create a list to be inserted after all the Messages have been processed
List requests = new List();
Once we reach 5 message.Ids in a single AsyncRequest.Params list, add it to requests.
If all the messages have been processed and there's a request with < 5 Ids in Params, add it to requests as well.
If requests.size() > 0 {
insert requests;
AsyncProcessor.StartBatch();
}
AsyncProcessor implements .Batchable and .AllowsCallouts, and queries ASyncRequest__c for any requests that need to be processed, which in this case will be our Messages list.
The execute() method takes the list of ASyncRequests, splits each Params value into its component Message Ids, and then queries the Message object for those particular Messages.
StartBatch() calls execute() with 1 record at a time, so that each execute() process will still contain fewer than the maximum 10 callouts.
Each Message is processed in a try/catch block that calls SendMessage(), sets Message.smsId = Twilio.smsId and sets Message.Sent = true.
If no smsId is returned, then the message was not sent, and I set a boolean bSidIsNull = true indicating that (at least) one message was not sent.
** If any message failed, no smsIds are returned EVEN FOR MESSAGES THAT WERE SUCCESSFUL **
After each batch of messages is processed, I check bSidIsNull; if true, then I go back over the list of messages and put any that do not have an smsId into a map indexed by the Twilio number I'm trying to send them From.
Since I limited each ASyncRequest to 5 messages, I still have the use of a callout to retrieve all of the messages sent from that Twilio.From number for the current date, using
client.getAccount().getMessages('From' => fromNumber, 'DateSent' => currentDate)
Then I can update the Message.smsIds for all of the messages that were successful, and add an error message to Message.Error_on_Send__c for any that failed.

How to handle delivery report in GSM Modem?

i want to use GSM Modem in an application for some purpose.
what i want is handling SMS delivery report for list of sent sms.
GSM Modem inbox & outbox are limited to 15 items. every time i read the inbox the gsm modem return a list an clear the list.
how to check delivery status of sms that had been deleted from GSM Modem inbox ?
i need something unique that enables me to identify each message.
every time i read the inbox the gsm modem return a list an clear the list.
Messages that are stored in modem's memory will not be removed after you read them. You just read message with at+cmgl={message id in storage} command and then remove it using at+cmgd={message id in storage} command (or not, as you wish. You can clear all modem's storages using at+cmgd=1,4 command).
Back to the question: after sending SMS, you'll get a response from modem, smth like this: +cmgs: {sms id, 0 to 255} OK. In case, if Service Center has delivered the SMS successfully, modem will return this response: +cds: {some id which does not matter} {PDU status report}. You need just decode this PDU to obtain status report, id of original SMS and other useful data. If sent sms's ID and ID from status report are equal, you have status report exactly for your message. Note, if you remove message from modem's storage before receiving of delivery report, you'll get report which will be containing all usual information, but status of delivery will be most likely 71 instead of 0.

Resources