Twilio queue overflow error: how large is the queue?

Twilio queue overflow error: how large is the queue?

Twilio 的 Message 资源有一个 "status" 属性 指示 SMS 消息是否为 "queued"、"sending"、"failed" 等。如果消息实例未能交付,一种可能的错误消息是 "Queue overflow"。在 Twilio 文档中,description for this error case 是:"You tried to send too many messages too quickly and your message queue overflowed. Try sending your message again after waiting some time."

错误代码 30001 中引用的队列是否是此资源的实例? https://www.twilio.com/docs/api/rest/queue

队列(在 30001 错误代码的情况下)是 Twilio 维护的东西吗?如果 Twilio 在幕后进行节流(每次发送 phone 号码排队 SMS 消息),该队列的大小是多少?在错误代码 30001 中引用的队列溢出发生之前,我们必须超过多少速率限制(每个 phone 个数字)?

Emily,消息队列与您在上面link输入的队列资源无关,它是由我们维护的。

Twilio 最多可以排队 4 小时的 SMS。这意味着,we can send out 1 sms per second,如果队列中的消息超过14,400条,则之后排队的所有消息都会失败并出现30001错误队列溢出,并且不会被发送。此信息适用于长代码号码。上面的link说明了其他场景的处理。

一些避免错误的建议:

  • 如果可能,请将消息限制在最多 160 个字符。但如果不是 可能的话,计算每条消息将有多少条 SMS 消息(如果 你不确定你总是可以 send 1 test message 看看有多少 您需要为该消息付费)。
  • 假设您的消息是 160 个字符, 将发送速率限制为每小时 3600 条消息 (1 messaage/sec * 60 sec/min * 60 min/hr).

如果您还有其他问题,请告诉我。

每个 Twilio phone 号码(发件人)都有一个单独的队列,其中可以排队 14400(4 小时 x 60 分钟 x 60 秒)个消息段。一秒发送1段

  • 什么是消息段?

A message segment is not a complete message but a part of a message. Normally SMS is sent in terms of message segments and all message segments are combined on the user’s mobile to create the actual SMS.

  • Twillio 消息段配置:

1 character = 8 bits(1 byte)

GSM encoding = 7 bit per character

UCS-2 encoding = 16 bit per character

Data Header = 6 bytes per segment

Summary: Each character takes 8 bits, If GSM encoding is used, each character will take 7 bits or if UCS-2 encoding is used, each char will take 16 bits. In the case of multiple segments, 6 bytes per segment will be used for data headers(responsible for combining all segments of the same SMS on user mobile)

  • 每个消息段的字符数:

GSM encoding when single segment = (140 char bytes x 8 bits)/ 7 bits = 160 characters

UCS-2 encoding when single segment = (140 char bytes x 8 bits)/ 16 bits = 70 characters

GSM encoding when multiple segment = ((140 char bytes - 6 header bytes) x 8 bits)/ 7 bits = 154 characters

UCS-2 encoding when multiple segment = ((140 char bytes - 6 header bytes) x 8 bits)/ 16 bits = 67 characters

根据您的消息使用的编码(通过 Twilio 管理员检查),您可以计算队列中一次可以有多少条 SMS。

参考文献:

  1. https://support.twilio.com/hc/en-us/articles/115002943027-Understanding-Twilio-Rate-Limits-and-Message-Queues
  2. https://www.twilio.com/blog/2017/03/what-the-heck-is-a-segment.html