capcom6 / android-sms-gateway

The SMS Gateway for Android™ app enables sending and receiving SMS messages through an API that can be accessed directly on the device or via a cloud server when direct device access is not possible.
https://sms-gate.app
Apache License 2.0
201 stars 53 forks source link

Messages and recipients hang in the "Processed" state #44

Closed Mapiiik closed 7 months ago

Mapiiik commented 7 months ago

Messages and recipients hang in the "Processed" state

If we want to process more messages (e.g. 50), after about 20-30 messages, all other messages will remain in the "Processed" state forever and are not sent at all (tested for 24 hours).

We send this way (encryption is disabled): 1) request a new message from the local phone server (one message to 1-3 recipients, length 200-300 characters) 2) save the ID from the reply 3) wait 5-10 seconds 4) request the message status for the saved ID 5) save status and ID to DB and continue from point 1) for new message

Then, after some time, we again request message statuses for messages that are not in the delivered state in DB.

At that point, the message won't even appear among the sent SMS in Google Messages.

example message status:

   "id":"Ch0CDBaJwhovohric7uG6",
   "isEncrypted":false,
   "recipients":[
      {
         "phoneNumber":"+XXXXXXXXXXXX",
         "state":"Processed"
      }
   ],
   "state":"Processed"
}

"Processed" state for mixed "Sent"/"Delivered"

Another thing I noticed is that if some recipients are in the "Delivered" state and some are in the "Sent" state, the global message state reverts from "Sent" to "Processed", which is a bit confusing, I think it should remain "Sent".

example message status:

   "id":"CAyydF5q4MKsNouxMZjS0",
   "isEncrypted":false,
   "recipients":[
      {
         "phoneNumber":"+XXXXXXXXXXXX",
         "state":"Sent"
      },
      {
         "phoneNumber":"+YYYYYYYYYYYY",
         "state":"Delivered"
      },
      {
         "phoneNumber":"+ZZZZZZZZZZZZ",
         "state":"Delivered"
      }
   ],
   "state":"Processed"
}
capcom6 commented 7 months ago

Hey there!

Thanks for reporting this! Can you tell me which app version you're on? Also, when you see messages stuck in Processed, is it happening with just one recipient, or does it happen with multiple folks too?

Just so you know, Processed actually means we've successfully passed the message to the Android messaging service, and there weren't any errors right off the bat. But it seems like something might be up on the Android end where the messages aren't getting sent out properly, and for some reason, our app isn't getting the send result. The problem might be due to Android having an internal queue for sending messages and it can overflow because actual sending is slow. You might wanna try putting in some delays between sending each message. Please see next link: https://sms.capcom.me/faq/#how-can-i-set-up-delays-between-sending-messages

And about the whole Processed state mix-up when you've got a mix of Sent and Delivered messages, you're spot on – it's a bug on our end. I'm on it and will make sure it gets squashed in the next update.

Cheers!

Mapiiik commented 7 months ago

Hello, thank you for your quick reply :-)

Thanks for reporting this! Can you tell me which app version you're on? Also, when you see messages stuck in Processed, is it happening with just one recipient, or does it happen with multiple folks too?

Yes, in this case all recipients are also in the "Processed" state.

Just so you know, Processed actually means we've successfully passed the message to the Android messaging service, and there weren't any errors right off the bat. But it seems like something might be up on the Android end where the messages aren't getting sent out properly, and for some reason, our app isn't getting the send result. The problem might be due to Android having an internal queue for sending messages and it can overflow because actual sending is slow. You might wanna try putting in some delays between sending each message. Please see next link: https://sms.capcom.me/faq/#how-can-i-set-up-delays-between-sending-messages

Today we tried to send about 60 messages and on our server side I increased the pause between sends to a random time between 60 and 90 seconds and everything seems to have gone fine, the "Processed" state was left only where there is a mix of Sent/Delivered. So it really probably looks like some problem in Android in getting new messages faster.

And about the whole Processed state mix-up when you've got a mix of Sent and Delivered messages, you're spot on – it's a bug on our end. I'm on it and will make sure it gets squashed in the next update.

That's great, I saw that there is already a pull request for that, looking forward to the new version.

Otherwise, thank you very much for creating this app, it's exactly what we needed :-)