RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / 问题 / 589410
Accepted
SLoN
SLoN
Asked:2020-11-10 19:59:19 +0000 UTC2020-11-10 19:59:19 +0000 UTC 2020-11-10 19:59:19 +0000 UTC

Kannel 短信网关。节流错误

  • 772

问候!收到节流错误后需要 Kannel 特定行为:

  1. 停止发送任何消息 60 秒。

此功能是通过编辑源文件 smsc_smpp.c 实现的:
#define SMPP_THROTTLING_SLEEP_TIME 60

  1. 超时后,不发送队列中的下一条消息,而是发送收到错误的消息。

也就是说,如果您发送消息“1”、“2”、“3”、“4”、“5”,并在消息“3”上收到节流错误,那么 Kannel 将在超时后发送消息“4”,然后是“5”,然后才是“3”。

收到节流错误后,Kannel 必须发送“3”,然后是“4”,然后是“5”。这样消息“3”在队列的开头出现,而不是在结尾。

谷歌搜索发现了很多类似的问题,但没有有效的解决方案。例如:

  • Kannel队列类型
  • 处理节流和消息队列满错误
  • 如何处理节流和消息队列满错误
sms
  • 2 2 个回答
  • 10 Views

2 个回答

  • Voted
  1. SLoN
    2020-11-11T15:11:51Z2020-11-11T15:11:51Z

    该问题已通过以下方式解决:

    I did the following patch to smsc/smsc_smpp.c in "case submit_sm_resp:"
    section from line 1609:
    change
    ***
    if (pdu->u.submit_sm_resp.command_status == SMPP_ESME_RTHROTTLED)
        time(&(smpp->throttling_err_time));
    else
        smpp->throttling_err_time = 0;
    
    bb_smscconn_send_failed(smpp->conn, msg, reason, octstr_format("0x%08lx/%s",
    pdu->u.submit_sm_resp.command_status,
    
     smpp_error_to_string(pdu->u.submit_sm_resp.command_status)));
    ***
    to
    ***
    if (pdu->u.submit_sm_resp.command_status == SMPP_ESME_RTHROTTLED) {
        time(&(smpp->throttling_err_time));
        /* Put the message back into the SMPP queue */
        gw_prioqueue_produce(smpp->msgs_to_send, msg);
    } else {
        smpp->throttling_err_time = 0;
        bb_smscconn_send_failed(smpp->conn, msg, reason,
    octstr_format("0x%08lx/%s", pdu->u.submit_sm_resp.command_status,
            smpp_error_to_string(pdu->u.submit_sm_resp.command_status)));
    }
    ***
    
    and in sms.c I have changed the function sms_priority_compare() to reverse
    time sorting order (for some reason it was LIFO):
    if (msg1->sms.time > msg2->sms.time)
        ret = -1;
    else if (msg1->sms.time < msg2->sms.time)
        ret = 1;
    -------------- next part --------------
    

    SMPP 节流错误处理

    但是,此更改不会影响多部分消息的各个部分的发送顺序。要解决此问题,您需要通过sms.c添加sms_priority_compare比较sms.id。将消息分成几部分时,sms_split此 ID 使用uuid_generate(part->sms.id). 最终函数sms_priority_compare如下所示:

    int sms_priority_compare(const void *a, const void *b)
    {
        int ret;
        Msg *msg1 = (Msg*)a, *msg2 = (Msg*)b;
        gw_assert(msg_type(msg1) == sms);
        gw_assert(msg_type(msg2) == sms);
    
        if (msg1->sms.priority > msg2->sms.priority)
            ret = 1;
        else if (msg1->sms.priority < msg2->sms.priority)
            ret = -1;
        else {
            if (msg1->sms.time > msg2->sms.time)
                ret = -1;
            else if (msg1->sms.time < msg2->sms.time)
                ret = 1;
            else {
                if (msg1->sms.id > msg2->sms.id)
                    ret = -1;
                else if (msg1->sms.id < msg2->sms.id)
                    ret = 1;
                else
                    ret = 0;           
            }
        }
    
        return ret;
    }
    
    • 2
  2. Best Answer
    SLoN
    2020-01-19T16:10:01Z2020-01-19T16:10:01Z

    我在 2016 年 11 月 11 日的回答中的解决方案一直有效,直到出现 Message Queue Full 错误消息。根据 SMS 中心的请求,当收到 MQF 错误时应发送以下消息。

    总要求:

    • 节流错误 - 超时 60 秒,重新发送错误消息
    • 消息队列已满 - 没有超时,重新发送队列中的下一条消息。错误消息放在队列的末尾

    解决方案:

    1. SMPP_THROTTLING_SLEEP_TIME正如我在问题中所写,超时持续时间是使用smsc_smpp.c
    2. sms.c在函数的文件中,sms_priority_compare我们按时间更改顺序。我们还为复合消息添加按 id 排序:

      if (msg1->sms.time > msg2->sms.time)
              ret = 1;
      else if (msg1->sms.time < msg2->sms.time)
              ret = -1;
      

      改成

      if (msg1->sms.time > msg2->sms.time)
          ret = -1;
      else if (msg1->sms.time < msg2->sms.time)
          ret = 1;
      else {
          if (msg1->sms.id > msg2->sms.id)
              ret = -1;
          else if (msg1->sms.id < msg2->sms.id)
              ret = 1;
          else
              ret = 0;           
      }
      
    3. 默认情况下,Kannel 在出现任何错误时将消息放在队列的末尾。smsc/smsc_smpp.c为了单独跟踪 TE,我们更改文件中的函数smpp_status_to_smscconn_failure_reason:

      static long smpp_status_to_smscconn_failure_reason(long status)
      {
          switch(status) {
              case SMPP_ESME_RMSGQFUL:
              case SMPP_ESME_RTHROTTLED:
              case SMPP_ESME_RX_T_APPN:
              case SMPP_ESME_RSYSERR:
                  return SMSCCONN_FAILED_TEMPORARILY;
                  break;
      
              default:
                  return SMSCCONN_FAILED_REJECTED;
          }
      }
      

      在

      static long smpp_status_to_smscconn_failure_reason(long status)
      {
          switch(status) {
              case SMPP_ESME_RMSGQFUL:
              case SMPP_ESME_RX_T_APPN:
              case SMPP_ESME_RSYSERR:
                  return SMSCCONN_FAILED_TEMPORARILY;
                  break;
      
              case SMPP_ESME_RTHROTTLED:
                  return SMPP_ESME_RTHROTTLED;
                  break;
      
              default:
                  return SMSCCONN_FAILED_REJECTED;
          }
      }
      
    4. 收到 MQF 后,我们更改消息时间。否则,当 TE 收到已收到 MQF 并移动到队列末尾的消息时,它们将被移动到队列的前面。在块smsc/smsc_smpp.c中函数的文件中,我们更改:handle_pducase submit_sm_resp:

      if (pdu->u.submit_sm_resp.command_status == SMPP_ESME_RTHROTTLED)
              time(&(smpp->throttling_err_time));
      else
              smpp->throttling_err_time = 0;    
      
      bb_smscconn_send_failed(smpp->conn, msg, reason, octstr_format("0x%08lx/%s", pdu->u.submit_sm_resp.command_status,
                                          smpp_error_to_string(pdu->u.submit_sm_resp.command_status)));
      

      在

      if (pdu->u.submit_sm_resp.command_status == SMPP_ESME_RTHROTTLED)
              time(&(smpp->throttling_err_time));
      else
              smpp->throttling_err_time = 0;    
      
      if (pdu->u.submit_sm_resp.command_status == SMPP_ESME_RMSGQFUL)
              time(&(msg->sms.time));    
      
      bb_smscconn_send_failed(smpp->conn, msg, reason, octstr_format("0x%08lx/%s", pdu->u.submit_sm_resp.command_status,
                                          smpp_error_to_string(pdu->u.submit_sm_resp.command_status)));
      
    5. 当我们收到 TE 错误时,我们将消息放在队列的头部。为此,在我们更改bb_smscconn.c函数的文件中:bb_smscconn_send_failed

      case SMSCCONN_FAILED_TEMPORARILY:     
             ...
             gwlist_produce(outgoing_sms, sms);
             break;
      
      case SMSCCONN_FAILED_SHUTDOWN:
             gwlist_produce(outgoing_sms, sms);
             break;
      

      在

      case SMSCCONN_FAILED_TEMPORARILY:     
             ...
             gwlist_produce(outgoing_sms, sms);
             break;
      
      case SMPP_ESME_RTHROTTLED:   
             gwlist_insert(outgoing_sms, 0, sms);
             break;
      
      case SMSCCONN_FAILED_SHUTDOWN:
             gwlist_produce(outgoing_sms, sms);
             break;
      
    6. 同样,您需要更改功能handle_split:

      case SMSCCONN_FAILED_TEMPORARILY:     
             ...
             gwlist_produce(outgoing_sms, msg);
             break;
      
      case SMSCCONN_FAILED_DISCARDED:
      

      在

      case SMSCCONN_FAILED_TEMPORARILY:     
             ...
             gwlist_produce(outgoing_sms, msg);
             break;
      
      case SMPP_ESME_RTHROTTLED:   
             gwlist_insert(outgoing_sms, 0, msg);
             break;
      
      case SMSCCONN_FAILED_DISCARDED:
      
    • 1

相关问题

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    如何停止编写糟糕的代码?

    • 3 个回答
  • Marko Smith

    onCreateView 方法重构

    • 1 个回答
  • Marko Smith

    通用还是非通用

    • 2 个回答
  • Marko Smith

    如何访问 jQuery 中的列

    • 1 个回答
  • Marko Smith

    *.tga 文件的组重命名(3620 个)

    • 1 个回答
  • Marko Smith

    内存分配列表C#

    • 1 个回答
  • Marko Smith

    常规赛适度贪婪

    • 1 个回答
  • Marko Smith

    如何制作自己的自动完成/自动更正?

    • 1 个回答
  • Marko Smith

    选择斐波那契数列

    • 2 个回答
  • Marko Smith

    所有 API 版本中的通用权限代码

    • 2 个回答
  • Martin Hope
    jfs *(星号)和 ** 双星号在 Python 中是什么意思? 2020-11-23 05:07:40 +0000 UTC
  • Martin Hope
    hwak 哪个孩子调用了父母的静态方法?还是不可能完成的任务? 2020-11-18 16:30:55 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    user207618 Codegolf——组合选择算法的实现 2020-10-23 18:46:29 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    Arch ArrayList 与 LinkedList 的区别? 2020-09-20 02:42:49 +0000 UTC
  • Martin Hope
    iluxa1810 哪个更正确使用:if () 或 try-catch? 2020-08-23 18:56:13 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5