0

Im using a 3rd party api service for a text sending job.

When I send around 5000 numbers as payload to the API, it works fine. I have noticed that sometimes when the payload count exceeds to 7000 or above. I receive the following error code in response from the api.

'Connection aborted.', RemoteDisconnected('Remote end closed connection without response',)
msg_dict['test'] = test
   msg_dict_json = json.dumps(msg_dict)
   data = {
     'apikey': apikey,
     'data': msg_dict_json,
   }
   res = requests.post('https://api.txtlocal.com/bulk_json/', data=data)
   return res

sample data obj:

data={
   "api_key": api_key,
   "data": '{"sender": "abc", "messages": [{"number": "+0000000000", "text": "some text"}], "test": true}'
}

data['data'] can be over 7000 objects (which is causing the issue)

I know there's a limit of 10000 users per api call for this api: https://api.txtlocal.com/bulk_json/ so my payload count always stays less than 10000.

PS: The request doesnt rollback, sms are sent to the user even when I get a response as mentioned above. Just I dont receive a positive response and it throws exception.

Also i want to mention that I have successfully been able to send 7 to 8000 sms with successful response but now its sending this issue.

Any help would be appreciated, thanks.

Fahad Hussain
  • 185
  • 1
  • 3
  • 15
  • I had a similar issue with the Salesforce API. The error means the remote server is having an issue, and NOT returning a proper HTTP response code. After debugging with Salesforce, it ended up being a bug in Java with garbage collection on their end. – FlipperPA Jul 10 '23 at 21:04
  • Hmmm...this is pretty serious issue if its from server side. Maybe I should raise an issue with the textlocal. BTW another thing I was thinking of is to send my packets in chunks. As in right now if I have a 7000 users packet, slice it down to maybe 2000 or something and then hit the API in loop since it is working for packets less than 5000 users a time? – Fahad Hussain Jul 12 '23 at 12:06
  • I've seen services that will just error out instead of instituting proper rate limiting. I'm not familiar with textlocal, but it is worth reaching out to them with the times you're seeing the errors to see if they see anything in logs on their side. With Salesforce, I ended up having to create a solid repro they could run in their own environment, ugh. – FlipperPA Jul 13 '23 at 14:14

1 Answers1

0

I can’t use comment, so I use answer.

Do you wait for the response ?

If so, is it a timeout issue ?

Thanks.

chunyen
  • 71
  • 6
  • If it is for `sending emails` or other similar functions, it is recommended to use `Celery` to send them. – chunyen Jul 10 '23 at 16:51