Session switching method for short message sending fault and short message gateway equipment
By building a session template library and a pre-warming session channel in the SMS gateway device, the problem of prolonged connection establishment when multiple SMS providers experience consecutive failures is solved, enabling rapid recovery and efficient switching of SMS sending.
Patent Information
- Application Number
- CN202511208502.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-27
- Publication Date
- 2025-11-14
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
When multiple SMS providers experience consecutive failures, existing SMS gateway devices take too long to establish connections during failover, affecting the timeliness of SMS delivery.
When establishing SMPP sessions with various SMS providers, the SMS gateway device simultaneously builds a session template library, which includes protocol version, window size and authentication parameters. It also calculates a fault risk score based on historical fault statistics and pre-establishes a warm-up session channel by performing TCP connection and TLS handshake for the best backup provider. When a fault is detected in the current provider session, the warm-up channel is directly activated to form a complete session.
By pre-building a session template library and warming up the session channel, the connection establishment time during failover is reduced, the efficiency of SMS provider switching is improved, and the rapid recovery of SMS sending is ensured.
Smart Images

Figure CN120957102A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of wireless communication technology, and in particular to a session switching method and SMS gateway device for SMS sending failure. Background Technology
[0002] With the widespread adoption of mobile internet applications, SMS verification codes have become a core technology for critical business processes such as user authentication, payment confirmation, and secure login. In enterprise-level SMS sending architectures, SMS gateway devices establish long-lived connections with multiple SMS providers via the SMPP protocol. Each SMPP session requires complex initialization processes, including protocol handshakes, authentication, and parameter negotiation, to establish a stable communication channel. Due to network instability, service fluctuations of provider SMS gateway devices, and operator session rate limiting policies, SMS gateway devices must possess rapid failover capabilities across multiple providers to ensure timely transfer to backup providers to continue providing service when the primary provider experiences an anomaly.
[0003] The SMS gateway failover technology in related technologies employs a failover strategy based on complete connection reconstruction to address vendor failure issues. Specifically, the SMS gateway device continuously monitors the SMPP session status with each vendor through heartbeat detection, response timeout monitoring, and error code analysis. When an anomaly is detected in the primary vendor session, the SMS gateway device immediately initiates the failover process. During the failover, the SMS gateway device first disconnects the existing connection with the failed vendor, and then selects a backup vendor as the failover target based on a preset vendor priority strategy. Next, the SMS gateway device establishes a connection with the selected backup vendor, including multiple stages such as TCP socket connection establishment, TLS security handshake negotiation, SMPP protocol version negotiation, identity authentication, transmission window size setting, and sequence number initialization. After the new SMPP session is fully established and its availability is verified, the SMS gateway device resubmits the backlogged SMS requests to the new vendor channel for transmission.
[0004] However, when multiple SMS providers fail consecutively due to network jitter during peak business periods, each SMS provider switch requires executing a connection establishment process from TCP to SMPP authentication. The network round-trip time of each connection establishment stage accumulates step by step during the failover process, extending the total switchover time to several seconds or even longer, thus affecting the overall timeliness of SMS sending services. Summary of the Invention
[0005] This application provides a session switching method and SMS gateway device for SMS sending failures, which improves the efficiency of SMS provider switching in the event of consecutive failures of multiple SMS providers.
[0006] Firstly, a session switching method for SMS sending failures is provided, applied to an SMS gateway device. The method includes: when establishing an SMPP session with each SMS provider, the SMS gateway device synchronously constructs a session template library, which at least includes protocol version, window size, and authentication parameters; the SMS gateway device calculates a failure risk score for each provider based on historical failure statistics; when the current provider starts sending SMS messages, the SMS gateway device selects the optimal backup provider based on the failure risk score; the SMS gateway device pre-executes TCP connection and TLS handshake for the optimal backup provider based on the session template corresponding to the optimal backup provider, obtaining a pre-warmed session channel; when a session failure of the current provider is detected, the SMS gateway device performs SMPP binding and authentication verification based on the session template corresponding to the optimal backup provider, activating the pre-warmed session channel into a complete SMPP session; and the SMS gateway device resubmits the SMS request to be sent within the session channel of the optimal backup provider.
[0007] By adopting the above technical solution, the SMS gateway device simultaneously builds a session template library containing protocol versions, window sizes, and authentication parameters when establishing SMPP sessions with various SMS providers, providing a standardized connection parameter foundation for subsequent rapid reconnection. By pre-establishing a warm-up session channel through TCP connection and TLS handshake for the optimal backup provider, the connection establishment time during failover is reduced. When a failure of the current provider session is detected, the SMS gateway device only needs to perform SMPP binding and authentication verification to activate the warm-up channel into a complete session, shortening the time interval from failure detection to service recovery, thereby improving the efficiency of SMS provider switching.
[0008] In conjunction with some embodiments of the first aspect, in some embodiments, the SMS gateway device calculates the fault risk score of each supplier based on the historical fault statistics of each supplier. Specifically, this includes: the SMS gateway device extracting the number of fault occurrences, fault duration, and fault recovery time of each supplier within a preset statistical period from historical logs to construct a supplier fault behavior dataset; the SMS gateway device calculating the fault frequency factor, persistence factor, and stability factor of each supplier based on the supplier fault behavior dataset, where the fault frequency factor is the ratio of the number of fault occurrences to the preset statistical period, the persistence factor is the ratio of the average fault duration to a preset baseline time, and the stability factor is the ratio of the maximum fault interval time to the minimum fault interval time; the SMS gateway device performing time-weighted processing on the fault frequency factor, persistence factor, and stability factor for different time periods based on a time decay function; and the SMS gateway device weighting and summing the weighted fault frequency factor, persistence factor, and stability factor according to preset weight coefficients to obtain the fault risk score of each supplier.
[0009] By adopting the above technical solution, the SMS gateway device transforms complex fault behaviors into quantifiable numerical indicators by calculating fault frequency factors, persistence factors, and stability factors. The fault frequency factor reflects the density of fault occurrences, the persistence factor reflects the impact of a single fault, and the stability factor characterizes the regularity of fault distribution. The application of a time decay function gives higher weight to recent fault data, while the weight of longer-term data gradually decreases. Finally, a comprehensive fault risk score is obtained through a weighted summation of preset weight coefficients, improving the accuracy of fault risk scores for each supplier and thus enhancing the accuracy of subsequently determining the optimal backup supplier.
[0010] In conjunction with some embodiments of the first aspect, in some embodiments, before the step of the SMS gateway device performing time-weighted processing on the fault frequency factor, persistence factor, and stability factor for different time periods based on a time decay function, the method further includes: the SMS gateway device marking fault records whose fault duration is greater than the average of the corresponding supplier's historical fault duration plus three standard deviations as abnormal fault records; the SMS gateway device calculating the density of abnormal fault records within a preset time window; the SMS gateway device marking preset time windows with a density greater than a preset density threshold as abnormal fault clustering periods; when an abnormal fault clustering period is detected, the SMS gateway device calculating an environmental degradation coefficient based on the ratio of the number of abnormal fault records within the abnormal fault clustering period to the total number of fault records within the abnormal fault clustering period; the SMS gateway device numerically correcting all fault records within the abnormal fault clustering period by dividing the fault duration of all fault records within the abnormal fault clustering period by the environmental degradation coefficient; the SMS gateway device merging the corrected fault records with the fault records from non-abnormal fault clustering periods; and the SMS gateway device recalculating the fault frequency factor, persistence factor, and stability factor based on the merged fault records from each supplier.
[0011] By adopting the above technical solution, the SMS gateway device identifies time periods potentially affected by the external environment by statistically analyzing the density of abnormal fault records within a preset time window and marking the periods of abnormal fault clustering. The environmental degradation coefficient is calculated based on the ratio of abnormal fault records to total fault records, quantifying the degree of impact of the external environment on the supplier's true performance. Numerical corrections are applied to all fault records within the abnormal fault clustering periods by dividing the fault duration by the environmental degradation coefficient, reducing the interference of external factors such as network environment deterioration and system maintenance on the supplier's true reliability assessment. The corrected fault records are merged with records from normal periods to recalculate the scoring factor, making the fault risk score more accurately reflect the supplier's own service capabilities and stability level.
[0012] In conjunction with some embodiments of the first aspect, in some embodiments, when the current supplier starts sending SMS messages, the SMS gateway device selects the optimal backup supplier based on the fault risk score. Specifically, this includes: when the current supplier starts sending SMS messages, the SMS gateway device obtains the real-time operating status parameters of each supplier; the SMS gateway device calculates the performance score of each supplier based on the real-time operating status parameters, where the performance score is inversely proportional to the supplier's connection count and load rate, and directly proportional to the supplier's response speed; the SMS gateway device normalizes the fault risk score and performance score of each supplier to obtain a standardized risk score and a standardized performance score; the SMS gateway device performs a weighted summation of the standardized risk score and standardized performance score based on preset risk weights and preset performance weights to obtain a comprehensive optimization score for each supplier; the SMS gateway device determines the supplier with the highest comprehensive optimization score and normal connection status as the optimal backup supplier.
[0013] By adopting the above technical solution, the performance score calculated by the SMS gateway device based on the real-time operating status parameters of each supplier is inversely proportional to the number of connections and load rate, and directly proportional to the response speed, reflecting the supplier's current service capabilities and resource utilization. Normalizing the fault risk score and performance score yields a standardized score, eliminating the influence between indicators of different dimensions, allowing historical reliability and real-time performance to be compared under a unified standard. A comprehensive optimization score is calculated by weighting and summing preset risk and performance weights, selecting the supplier with the highest comprehensive optimization score and normal connection status as the optimal backup, reducing the possibility of selecting a supplier with historically good performance but currently declining performance as a backup.
[0014] In conjunction with some embodiments of the first aspect, in some embodiments, after the step of the SMS gateway device performing a weighted summation of the standardized risk score and the standardized performance score based on a preset risk weight and a preset performance weight to obtain a comprehensive preferred score for each supplier, the method further includes: the SMS gateway device calculating a performance change gradient based on the changing trends of the SMS sending success rate and average response time of each supplier; the SMS gateway device predicting the performance degradation probability of each supplier within a preset time window based on the performance change gradient; the SMS gateway device marking suppliers whose performance degradation probability is greater than a preset probability threshold as potential risk suppliers; and the SMS gateway device multiplying the comprehensive preferred score of the potential risk suppliers by a weighting coefficient, the weighting coefficient being determined based on the performance degradation probability.
[0015] By adopting the above technical solution, the SMS gateway device calculates the performance change gradient based on the SMS sending success rate and average response time change trends of each supplier. This performance change gradient provides a mathematical basis for predicting the performance degradation probability of each supplier within a preset time window, enabling the SMS gateway device to proactively identify suppliers that may experience performance degradation. Suppliers with a performance degradation probability greater than a preset probability threshold are marked as potential risk suppliers. By multiplying the comprehensive selection score of potential risk suppliers by a weighting coefficient determined based on the performance degradation probability, the priority of suppliers with performance degradation risk is reduced during the supplier selection process. This reduces the likelihood of selecting suppliers with impending performance problems as backups, thereby improving the stability of SMS service after failover.
[0016] In conjunction with some embodiments of the first aspect, in some embodiments, the SMS gateway device pre-executes TCP connection and TLS handshake for the optimal backup vendor based on the session template corresponding to the optimal backup vendor to obtain a pre-warmed session channel. Specifically, this includes: the SMS gateway device establishing a TCP socket connection based on the network address information of the optimal backup vendor and setting connection timeout and keep-alive parameters; the SMS gateway device initiating TLS handshake negotiation according to the encryption configuration parameters in the session template corresponding to the optimal backup vendor to obtain the pre-warmed session channel; the SMS gateway device sending an SMPP protocol capability probe message through the encrypted channel after the TLS handshake is completed; and the SMS gateway device adjusting the protocol version parameters and transmission window size parameters in the session template based on the response result of the SMPP protocol capability probe message.
[0017] By adopting the above technical solution, the protocol version parameters and transmission window size parameters in the session template are dynamically adjusted based on the response results of the SMPP protocol capability probe message, which reduces the handover failure caused by protocol version mismatch or improper transmission parameters, thereby improving the success rate and communication efficiency of the fault handover process.
[0018] In conjunction with some embodiments of the first aspect, in some embodiments, after the step of the SMS gateway device resubmitting the SMS request to be sent in the session channel of the optimal backup provider, the method further includes: after detecting network connectivity of the faulty provider, the SMS gateway device re-establishes a test connection based on the session template corresponding to the faulty provider; the SMS gateway device sends a preset number of test SMS requests through the test connection, the preset number being determined based on the average concurrent processing capacity of the faulty provider before the fault; the SMS gateway device statistically analyzes the success rate, average response time, and connection stability index of the test SMS requests, the connection stability index being the ratio of the number of connection drops during the test to the test duration; the SMS gateway device calculates a recovery credibility score based on the success rate, average response time, and connection stability index; when the recovery credibility score is greater than a preset credibility threshold, the SMS gateway device marks the status of the faulty provider as available; the SMS gateway device performs a trust level downgrade processing on the faulty provider based on the duration of the fault, the trust level downgrade processing being the application of a penalty coefficient to the fault risk score of the provider within a preset observation period, the penalty coefficient being proportional to the duration of the fault.
[0019] By adopting the above technical solutions, the faulty supplier recovery detection mechanism reduces the long-term idleness of high-quality supplier resources. Through proactive recovery verification and reliability assessment, SMS gateway devices can promptly identify and reactivate recovered suppliers, improving overall resource utilization efficiency. Recovery reliability scoring based on test results ensures that only suppliers with restored service capabilities are reactivated, reducing the risk of secondary failures caused by prematurely activating incompletely recovered suppliers. By imposing continuous penalty coefficients on suppliers with poor fault performance, their reliability deficiencies are reflected in subsequent risk assessments, providing SMS gateway devices with a more accurate basis for supplier selection.
[0020] In a second aspect, embodiments of this application provide a text messaging gateway device, which includes: one or more processors and a memory; the memory is coupled to the one or more processors, and the memory is used to store computer program code, which includes computer instructions, and the one or more processors call the computer instructions to cause the text messaging gateway device to perform the method described in the first aspect and any possible implementation thereof.
[0021] Thirdly, embodiments of this application provide a computer program product containing instructions that, when the computer program product is run on an SMS gateway device, cause the SMS gateway device to perform the method described in the first aspect and any possible implementation thereof.
[0022] Fourthly, embodiments of this application provide a computer-readable storage medium including instructions that, when executed on a short message gateway device, cause the short message gateway device to perform the method described in the first aspect and any possible implementation thereof.
[0023] It is understood that the SMS gateway device provided in the second aspect, the computer program product provided in the third aspect, and the computer storage medium provided in the fourth aspect are all used to execute the methods provided in the embodiments of this application. Therefore, the beneficial effects they can achieve can be referred to the beneficial effects in the corresponding methods, and will not be repeated here.
[0024] One or more technical solutions provided in the embodiments of this application have at least the following technical effects or advantages: 1. Because the SMS gateway device synchronously builds a session template library containing protocol versions, window sizes, and authentication parameters when establishing SMPP sessions with each SMS provider, it provides a standardized connection parameter foundation for subsequent rapid reconnection. By pre-establishing a warm-up session channel through TCP connection and TLS handshake for the optimal backup provider, the connection establishment time during failover is reduced. When a failure of the current provider session is detected, the SMS gateway device only needs to perform SMPP binding and authentication verification to activate the warm-up channel into a complete session, shortening the time interval from failure detection to service recovery, thereby improving the efficiency of SMS provider switching.
[0025] 2. By statistically analyzing the density of abnormal fault records within a preset time window and marking periods of abnormal fault clustering, the SMS gateway device identifies time periods potentially affected by the external environment. The environmental degradation coefficient is calculated based on the ratio of abnormal fault records to total fault records, quantifying the impact of the external environment on the supplier's true performance. Numerical corrections are applied to all fault records within the abnormal fault clustering period by dividing the fault duration by the environmental degradation coefficient, reducing the interference of external factors such as network environment deterioration and system maintenance on the supplier's true reliability assessment. The corrected fault records are then merged with records from normal periods to recalculate the scoring factor, making the fault risk score more accurately reflect the supplier's service capabilities and stability level.
[0026] 3. Because the SMS gateway device calculates the performance change gradient based on the SMS sending success rate and average response time trends of each supplier, this performance change gradient provides a mathematical basis for predicting the performance degradation probability of each supplier within a preset time window. This allows the SMS gateway device to proactively identify suppliers that may experience performance degradation. Suppliers with a performance degradation probability greater than a preset probability threshold are marked as potential risk suppliers. By multiplying the comprehensive selection score of potential risk suppliers by a weighting coefficient determined based on the performance degradation probability, the priority of suppliers with performance degradation risk is reduced during the supplier selection process. This reduces the likelihood of selecting suppliers with impending performance problems as backups, thereby improving the stability of SMS service after failover. Attached Figure Description
[0027] Figure 1 This is a flowchart illustrating a session switching method for SMS sending failure in an embodiment of this application.
[0028] Figure 2 This is a flowchart illustrating a method for determining the optimal backup supplier in an embodiment of this application.
[0029] Figure 3 This is a flowchart illustrating a fault supplier recovery method in an embodiment of this application.
[0030] Figure 4 This is a schematic diagram of the physical device structure of a text message gateway device in the embodiments of this application. Detailed Implementation
[0031] The terminology used in the following embodiments of this application is for the purpose of describing particular embodiments only and is not intended to be limiting of this application. As used in the specification and appended claims of this application, the singular expressions “a,” “an,” “the,” “the,” “the,” and “this” are intended to include the plural expressions as well, unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used in this application refers to and includes any or all possible combinations of one or more of the listed items.
[0032] Hereinafter, the terms "first" and "second" are used for descriptive purposes only and should not be construed as implying or suggesting relative importance or implicitly indicating the number of indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature, and in the description of the embodiments of this application, unless otherwise stated, "multiple" means two or more.
[0033] This application provides a session switching method and SMS gateway device for SMS sending failures, which improves the efficiency of SMS provider switching in the event of consecutive failures of multiple SMS providers.
[0034] The following describes a session switching method for SMS sending failure in an embodiment of this application: Please see Figure 1 This is a flowchart illustrating a session switching method for SMS sending failure in an embodiment of this application.
[0035] S101. When establishing SMPP sessions with various SMS providers, the SMS gateway device simultaneously builds a session template library.
[0036] In this context, the SMS gateway device refers to the core network device deployed within an enterprise's SMS sending gateway. It represents the middleware device responsible for establishing communication connections with multiple SMS providers and managing SMS distribution. The SMS provider refers to a third-party operator or service provider offering SMS sending services, such as China Mobile, China Unicom, China Telecom, or a professional SMS service company. An SMPP session refers to a long-connection communication session established based on the Short Message Peer-to-Peer protocol, representing the standardized communication channel for SMS transmission between the SMS gateway device and the SMS provider. The session template library represents a collection of data structures storing connection parameters and configuration information for each provider, including key configuration items such as protocol version, window size, and authentication parameters. For example, when the SMS gateway device establishes an SMPP session with provider A, it synchronously records parameters such as the provider's protocol version (3.4), transmission window size (10), and username "gateway_user" into the session template library.
[0037] Specifically, the SMS gateway device first reads the basic configuration information of each provider, including server address, port number, authentication credentials, etc. Then, it initiates SMPP connection requests with each provider one by one, completing the entire session establishment process, including TCP connection establishment, TLS security handshake, SMPP protocol version negotiation, identity authentication verification, and transmission parameter negotiation. Upon successful establishment of each SMPP session, the SMS gateway device extracts and structures the actual negotiation result parameters of that provider (such as the final determined protocol version, the actual negotiated window size, and the valid authentication token) into the session template library, forming a standardized connection template for that provider. This provides parameter basis for subsequent rapid reconnection and warm-up connections.
[0038] S102. The SMS gateway device calculates the fault risk score of each supplier based on the historical fault statistics of each supplier.
[0039] Historical fault statistics refer to the recorded information of past fault events of each supplier extracted from the operation logs of the SMS gateway device. This data is used to represent a structured dataset containing dimensions such as fault occurrence time, duration, recovery time, and fault type. The fault risk score is used to represent a comprehensive assessment value of the probability and impact of future faults for each supplier.
[0040] Specifically, the SMS gateway device first extracts complete fault records for each supplier within a preset statistical period (e.g., the past 30 days) from historical operation logs, including timestamps, durations, and recovery status of various fault events such as connection interruptions, response timeouts, and authentication failures. Then, the extracted raw data is cleaned and verified, removing abnormal records and duplicate data to construct a standardized supplier fault behavior dataset. Next, abnormal fault detection and data correction are performed: the SMS gateway device calculates the mean μ and standard deviation σ of the historical fault duration for each supplier, marking records with fault durations greater than μ + 3σ as abnormal fault records. Then, the density of abnormal fault records is statistically analyzed in fixed time windows (e.g., 4 hours), calculated as density = number of abnormal fault records within the time window / time window duration. When the density exceeds a preset density threshold, the time window is marked as an abnormal fault cluster period. For detected abnormal fault cluster periods, an environmental degradation coefficient is calculated, specifically as environmental degradation coefficient = number of abnormal fault records within the abnormal fault cluster period / total number of fault records within the abnormal fault cluster period. Then, the fault duration of all fault records within the specified period is numerically corrected using the formula: Corrected fault duration = Original fault duration / Environmental degradation coefficient, to eliminate the impact of external environmental degradation on the supplier's actual performance. The corrected fault records are then merged with fault records from non-abnormal fault clustering periods to form a complete corrected fault dataset. Subsequently, three core evaluation factors are calculated based on the corrected fault behavior dataset: the fault frequency factor is calculated using the formula (number of fault occurrences / preset statistical period), the persistence factor is calculated using the formula (average fault duration / preset baseline time), and the stability factor is calculated using the formula (maximum fault interval / minimum fault interval). Finally, a time decay function is used to weight the three factors for different time periods. The time decay function can be expressed as an exponential decay function f(t) = e^(-t / t). -λtThe function λ is the attenuation coefficient (usually set to 0.1), and t is the number of days since the current time. This function gives higher weight to recent data and gradually reduces the weight of older data. Finally, the three time-weighted factors are linearly combined according to preset weight coefficients. The calculation formula is: Fault Risk Score = w1 × Time-weighted Fault Frequency Factor + w2 × Time-weighted Persistence Factor + w3 × Time-weighted Stability Factor, where w1, w2, and w3 are the weight coefficients for fault frequency, persistence, and stability (e.g., 0.4, 0.3, 0.3), respectively. The final comprehensive fault risk score for each supplier is obtained.
[0041] In some embodiments, the fault risk score can be calculated in multiple ways: Optionally, a sliding time window statistical method can be adopted. First, the 30-day statistical period is divided into six 5-day time windows, and the fault frequency factor, persistence factor, and stability factor are calculated in each window. Then, attenuation weights are set for the six time windows (e.g., weight 0.3 for the first window, 0.25 for the second window, 0.2 for the third window, 0.15 for the fourth window, 0.08 for the fifth window, and 0.02 for the sixth window), with the weight increasing as the time is closer to the current time. Finally, the weighted value of each factor is calculated in each time window, and then a second weighted sum is performed on the time dimension to obtain the final time-weighted factor value. Optionally, a hierarchical anomaly detection and correction mechanism can also be adopted. First, the 3σ criterion is used to identify the anomaly of individual fault events, and faults with a duration exceeding μ+3σ are marked as individual abnormal faults. Then, a density clustering algorithm is used to detect abnormal clusters in the time dimension, with a time window of 4 hours and a density threshold of 3 abnormal faults per window. Next, the environmental degradation coefficient is calculated, with the specific formula being Environmental degradation coefficient = Number of abnormal faults / (Number of abnormal faults + Number of normal faults), and the value range is 0-1. Finally, all fault records within the abnormal period are linearly corrected, with the correction formula being Corrected duration = Original duration × (1 - Environmental degradation coefficient × 0.5), and the impact of external environmental factors is reduced through weight reduction.
[0042] It is understandable that other methods can be used to calculate the fault risk score, such as probability assessment based on Bayesian inference or multi-scale time analysis using wavelet transform, etc., which are not limited here.
[0043] S103. When the current supplier starts sending SMS messages, the SMS gateway device selects the best backup supplier based on the fault risk score.
[0044] Specifically, the SMS gateway device selects the supplier with the lowest fault risk score as the optimal backup supplier based on the fault risk score calculated in step S102.
[0045] S104. The SMS gateway device pre-executes TCP connection and TLS handshake for the optimal backup supplier based on the session template corresponding to the optimal backup supplier, and obtains a pre-warmed session channel.
[0046] In this context, a TCP connection represents a reliable connection established at the transport layer and forms the underlying network foundation for an SMPP session. A TLS handshake refers to the handshake process of the transport layer security protocol, used to represent the negotiation process for establishing an encrypted secure channel based on a TCP connection. A warm-up session channel represents an intermediate connection that has completed the TCP connection and TLS handshake but has not yet undergone SMPP protocol binding, possessing the ability to quickly activate into a complete SMPP session.
[0047] Specifically, this step is executed immediately after the optimal backup vendor is determined, aiming to prepare the connection layer in advance for possible failover. The SMS gateway device first extracts network address information from the session template corresponding to the optimal backup vendor, including basic connection parameters such as server IP address, port number, and connection protocol type. Then, based on these parameters, it creates a TCP socket connection, setting appropriate connection timeout (e.g., 5 seconds) and keep-alive parameters (e.g., heartbeat interval of 30 seconds) to ensure connection stability and timely anomaly detection capabilities. After the TCP connection is successfully established, the SMS gateway device immediately initiates a TLS handshake negotiation according to the encryption configuration parameters in the session template, completing the security layer establishment process, including certificate verification, key exchange, and encryption algorithm negotiation, forming an encrypted secure communication channel. Ultimately, a pre-warmed session channel is obtained, complete with network and security layer preparations, and can be quickly activated into a full SMPP session at any time.
[0048] In some embodiments, pre-warming session channels can be established and maintained in several ways: Optionally, a connection pool management approach can be adopted. First, a dedicated pre-warming connection pool is created, and a certain number of TCP connection resources are pre-allocated to each potential backup vendor. Then, the health status of the connections in the pool is checked periodically, and connections that have timed out or are abnormal are cleaned up and rebuilt in a timely manner. Finally, the size of the connection pool is dynamically adjusted according to the business load, increasing the number of pre-warming connections during peak periods and reducing resource consumption during off-peak periods. Optionally, an asynchronous non-blocking approach can also be adopted. First, a non-blocking I / O model is used to concurrently initiate TCP connection requests to multiple backup vendors to avoid the impact of a single connection establishment failure on overall efficiency. Then, an event-driven mechanism is used to monitor the establishment progress of each connection, and a TLS handshake is immediately performed on successfully established connections. Finally, a connection status monitoring mechanism is established to track the availability status of the pre-warming channel in real time, ensuring that it can be put into use immediately when needed.
[0049] It is understandable that other methods can be used to establish and maintain warm-up session channels, such as priority-based hierarchical connection management and intelligent reconnection mechanisms, which are not limited here.
[0050] S105. When a failure of the current supplier session is detected, the SMS gateway device performs SMPP binding and authentication verification based on the session template corresponding to the best backup supplier, and activates the preheating session channel into a complete SMPP session.
[0051] Specifically, this step is triggered immediately upon determining that the current supplier session is abnormal. The fault detection module of the SMS gateway device continuously monitors the current supplier session status through various means such as heartbeat monitoring, response time detection, and error code analysis. Once an abnormal situation such as connection loss, response timeout exceeding the threshold, or receiving a fault error code is detected, the fault switching process is immediately triggered. The SMS gateway device first extracts the authentication parameters required for SMPP binding from the session template corresponding to the optimal backup supplier, including key authentication information such as username, password, SMS gateway device type, and interface version. Then, based on the established pre-warmed session channel (which has completed TCP connection and TLS handshake and is in a secure communication ready state), it directly sends an SMPP binding request message to declare the client identity and service type to the backup supplier's SMPP server. In the binding request, the SMS gateway device specifies an appropriate binding type (such as sender binding, receiver binding, or transceiver binding), sets a reasonable transmission window size, and an initial sequence number value. After receiving the binding request, the supplier server performs authentication to confirm the validity of the username and password and access permissions. After successful authentication, the server returns a binding response message, confirming that the session has been successfully established. At this point, the warm-up session channel has been successfully activated as an SMPP session with full SMS sending and receiving capabilities, and can be used immediately for SMS transmission tasks.
[0052] S106. The SMS gateway device resubmits the SMS request to be sent in the session channel of the best backup vendor.
[0053] Specifically, this step is executed immediately after the backup provider session is successfully activated. The SMS gateway device first retrieves all pending SMS requests from its internal SMS queue management module. These requests may include SMS messages that failed to send due to a fault, SMS messages interrupted during transmission, and newly received but unprocessed SMS messages. The SMS gateway device performs status checks and priority sorting on these SMS requests, ensuring that high-priority SMS messages (such as verification code SMS messages and alarm SMS messages) are processed first. Then, it updates the target provider identifier of these SMS requests from the original failed provider to the newly activated optimal backup provider, completing the message routing switch. Next, the SMS gateway device resubmits these SMS requests through the activated backup provider SMPP session channel, according to the SMPP protocol specifications, including constructing the submit_sm message, setting appropriate protocol parameters, and managing sequence numbers and transmission windows.
[0054] In the above embodiments, when establishing SMPP sessions with each SMS provider, the SMS gateway device simultaneously constructs a session template library containing protocol versions, window sizes, and authentication parameters, providing a standardized connection parameter foundation for subsequent rapid reconnection. By pre-establishing a warm-up session channel through TCP connection and TLS handshake for the optimal backup provider, the connection establishment time during failover is reduced. When a failure of the current provider session is detected, the SMS gateway device only needs to perform SMPP binding and authentication verification to activate the warm-up channel into a complete session, shortening the time interval from failure detection to service recovery, thereby improving the efficiency of SMS provider switching.
[0055] However, the above embodiments are mainly based on historical data for risk assessment. They lack consideration of real-time performance status when selecting suppliers. This may result in the selection of suppliers with good historical performance but declining current performance as backups. At the same time, it is difficult to predict the future performance trend of suppliers, which may lead to the switch supplier experiencing performance problems again soon.
[0056] In some embodiments, to further improve the accuracy and foresight of the selection of the optimal alternative supplier, the following method for determining the optimal alternative supplier may be performed.
[0057] The following describes a method for determining the optimal backup supplier in an embodiment of this application: Please see Figure 2 This is a flowchart illustrating a method for determining the optimal backup supplier in an embodiment of this application.
[0058] S201. When the current supplier starts sending SMS messages, the SMS gateway device obtains the real-time operating status parameters of each supplier.
[0059] Here, "Current Supplier" refers to the primary supplier currently handling SMS sending tasks, representing the service provider currently selected by the system to assume responsibility for SMS transmission. "Start Sending SMS" indicates the official initiation point of the SMS sending task, including the initial stages such as task queue processing, connection establishment, and sending requests. "Current Suppliers" refers to all available SMS service providers configured in the system.
[0060] Specifically, this step is executed in parallel with the SMS sending task. The SMS gateway device collects real-time status data from all established providers, monitoring both network-level connection quality metrics and application-level service performance metrics. Network-level monitoring includes basic network metrics such as TCP connection establishment time, round-trip time (RTT), packet loss rate, and bandwidth utilization. This data is obtained by sending probe packets and analyzing network responses. Application-level monitoring includes business-related metrics such as SMPP session response time, SMS sending success rate, provider-returned error code distribution, current processing queue length, and concurrent connections. This data is extracted in real-time from SMPP protocol interaction processes and business logs. The SMS gateway device also acquires the provider's resource usage status, such as CPU load, memory usage, and service availability status. This information is obtained through monitoring interfaces provided by the provider or through proactive probing by the SMS gateway device. All collected real-time operational status parameters are timestamped and verified to ensure data accuracy and timeliness, and stored in a high-speed cache for subsequent performance scoring calculations.
[0061] S202, The SMS gateway device calculates the performance score of each supplier based on real-time operating status parameters.
[0062] The performance score for each supplier is a quantitative performance indicator calculated based on real-time operational parameters. It represents a comprehensive evaluation of each supplier's current service capabilities and response quality, with values ranging from 0 to 1, where higher values indicate better performance. For example, based on supplier A's current average response time of 80ms, success rate of 99.5%, and connection latency of 10ms, its performance score is calculated to be 0.85, while supplier B, with a longer response time of 200ms, has a performance score of only 0.62.
[0063] Specifically, this step is executed immediately after the real-time status parameter collection in step S201 is completed. The SMS gateway device first performs data preprocessing on the collected real-time operating status parameters, including outlier detection and data standardization, removing obviously abnormal monitoring data points and supplementing missing data through reasonable interpolation. Then, the SMS gateway device decomposes the real-time performance indicators into four core performance factors for quantitative calculation: the response performance factor is calculated using the formula (baseline response time / current average response time), reflecting the supplier's response speed; the reliability performance factor is calculated using the formula (current success rate / standard success rate baseline), assessing the supplier's service stability; the network performance factor is calculated using the formula (baseline network latency / current network latency), measuring network connection quality; and the load performance factor is calculated using the formula (maximum processing capacity - current queue length) / maximum processing capacity, assessing the supplier's current load status. Next, the SMS gateway device normalizes the four performance factors, mapping all factor values to the 0-1 range to ensure that indicators with different dimensions can be effectively calculated comprehensively. Finally, the four normalized performance factors are weighted and summed according to the preset weight coefficients. The calculation formula is: Performance Score = w1 × Normalized Response Performance Factor + w2 × Normalized Reliability Performance Factor + w3 × Normalized Network Performance Factor + w4 × Normalized Load Performance Factor, where w1, w2, w3, and w4 are the weight coefficients of each performance dimension (e.g., 0.3, 0.4, 0.2, and 0.1), and the final comprehensive performance score of each supplier is obtained.
[0064] In some embodiments, performance scores can be calculated in multiple ways: Optionally, a dynamic weight adjustment mechanism can be adopted. First, the weight coefficients of each performance factor are dynamically adjusted according to the characteristics of the current business scenario. For example, the weight of the load performance factor is increased in high-concurrency scenarios, and the weight of the response performance factor is increased in latency-sensitive scenarios. Then, a weight learning mechanism is established. By analyzing the feedback of the effects of historical switching decisions, the gradient descent algorithm is used to optimize the weight coefficient configuration. Finally, weight boundary constraints are set to ensure that each weight coefficient changes within a reasonable range, avoiding extreme weight allocation from affecting the stability of the score. Optionally, a multi-time-granularity performance evaluation method can also be adopted. First, each performance factor is calculated separately in different time windows (such as the most recent 1 minute, 5 minutes, and 15 minutes) to obtain short-term and medium-term performance data. Then, an exponential smoothing algorithm is used to fuse the performance factors of different time granularities. The formula is: Fusion Factor = α × Short-term Factor + β × Medium-term Factor + γ × Long-term Factor, where α + β + γ = 1. Finally, a time decay mechanism is used to reduce the influence weight of historical data, so that the performance score can better reflect the current true state of the supplier.
[0065] It is understandable that other methods can be used to achieve computational performance scoring, such as multi-dimensional evaluation based on fuzzy logic or nonlinear performance modeling using neural networks, etc., which are not limited here.
[0066] S203, the SMS gateway device normalizes the fault risk scores and performance scores of each supplier to obtain standardized risk scores and standardized performance scores.
[0067] Specifically, this step is executed after calculating the performance score in step S202. The SMS gateway device first collects fault risk scores and performance scores from all suppliers, constructing two independent score vectors. Then, it performs statistical analysis on both types of scores, calculating the minimum, maximum, mean, and standard deviation of the fault risk score. Similarly, it calculates the corresponding statistical characteristic values of the performance score, providing a reference benchmark for normalization. Next, the SMS gateway device uses the Min-Max standardization method to normalize the fault risk score. The calculation formula is: Standardized Risk Score = (Original Risk Score - Minimum Risk Score) / (Maximum Risk Score - Minimum Risk Score), mapping all supplier risk scores to the 0-1 range, where 0 represents the lowest risk and 1 represents the highest risk. For the performance score, the Min-Max standardization method is also used, with the calculation formula: Standardized Performance Score = (Original Performance Score - Minimum Performance Score) / (Maximum Performance Score - Minimum Performance Score), mapping all supplier performance scores to the 0-1 range, where 0 represents the lowest performance and 1 represents the highest performance. The SMS gateway device also performs data validity verification, checking whether the normalized values are within a reasonable range and applying appropriate boundary constraints to outliers.
[0068] S204. The SMS gateway device performs a weighted sum of the standardized risk score and standardized performance score based on preset risk weight and preset performance weight to obtain a comprehensive optimal score for each supplier.
[0069] Among them, the preset risk weight refers to the weight coefficient pre-set in the system configuration to quantify the importance of risk scores, and is used to represent the proportion of influence of fault risk factors in the overall supplier evaluation. The preset performance weight refers to the weight coefficient pre-set in the system configuration to quantify the importance of performance scores, and is used to represent the proportion of influence of real-time performance factors in the overall supplier evaluation. The standardized risk score refers to the fault risk score data after normalization processing in step S203. The standardized performance score refers to the performance score data after normalization processing in step S203. The comprehensive selection score refers to the comprehensive supplier evaluation index obtained by integrating the two dimensions of risk and performance, and is used to represent the overall service quality and selection priority of the supplier. For example, if the risk weight is set to 0.4, the performance weight is set to 0.6, the standardized risk score of supplier A is 0.3, and the standardized performance score is 0.8, then its comprehensive selection score = 0.4 × (1 - 0.3) + 0.6 × 0.8 = 0.76.
[0070] Specifically, this step is executed immediately after the normalization process in step S203. The SMS gateway device first reads the preset risk weight and performance weight parameters from its configuration. These weights reflect the relative importance the business places on risk control and performance, and are typically configured based on the enterprise's business characteristics and SLA requirements. The SMS gateway device verifies the validity of the weight parameters, ensuring that the sum of the risk weight and performance weight equals 1, guaranteeing the mathematical meaning of the weighted summation result. Then, the standardized risk score is processed in reverse. Since a lower risk score indicates a better supplier, and the final comprehensive evaluation score needs to follow the principle of "the higher the better," the risk score is converted into a positive indicator using the formula (1 - standardized risk score). Next, the SMS gateway device performs a weighted summation calculation, applying the formula Comprehensive Evaluation Score = Preset Risk Weight × (1 - Standardized Risk Score) + Preset Performance Weight × Standardized Performance Score to each supplier, obtaining a comprehensive evaluation result that integrates historical risk performance and current performance status. During the calculation process, the SMS gateway device also performs a numerical validity check to ensure the calculation result is within a reasonable range and records the detailed score composition of each supplier, including risk contribution and performance contribution.
[0071] S205, the SMS gateway device calculates the performance change gradient based on the SMS sending success rate and average response time change trends of each supplier.
[0072] Among them, SMS delivery success rate refers to the ratio of the number of SMS messages successfully sent by the supplier within a specific time window to the total number of sending requests, reflecting the supplier's service stability. Average response time refers to the average time it takes for the supplier to process SMS sending requests, reflecting the supplier's service response efficiency. The trend indicates the pattern and direction of change of SMS delivery success rate and average response time over time, including trends such as rising, falling, and fluctuating. Performance change gradient is a quantitative indicator describing the rate and direction of change of supplier performance metrics, used to represent the degree and speed of performance improvement or deterioration. For example, if supplier A's success rate decreased from 99.2% to 97.8% and its average response time increased from 80ms to 120ms in the past hour, the calculated performance change gradient is -0.15, indicating a downward trend in performance.
[0073] Specifically, this step is performed periodically by the SMS gateway device during vendor performance trend analysis, typically in conjunction with the monitoring SMS gateway device. The SMS gateway device first extracts historical performance data for each vendor within a preset time window (e.g., the past 60 minutes) from the performance monitoring database, including SMS sending success rate and average response time records at 5-minute intervals. Then, the SMS gateway device preprocesses the extracted time-series data, including outlier detection and data smoothing, using moving averages or exponential smoothing algorithms to reduce the impact of data noise on trend analysis. Next, the SMS gateway device performs trend analysis on success rate and response time data separately: for success rate trends, a linear regression method is used to fit the data sequence, and the slope of the regression line is calculated as the success rate gradient; a positive value indicates an upward trend in success rate, and a negative value indicates a downward trend. For response time trends, linear regression is also used to calculate the slope, but since an increase in response time represents performance degradation, the slope needs to be negative as the response time performance gradient. The SMS gateway device then standardizes the gradients of the two dimensions to eliminate the influence of different indicator units, and then performs weighted fusion according to preset weights (such as success rate gradient weight 0.6 and response time gradient weight 0.4). The calculation formula is performance change gradient = w1 × standardized success rate gradient + w2 × standardized response time gradient, and finally obtains a quantitative indicator that reflects the overall performance change trend of the supplier.
[0074] In some embodiments, the performance change gradient can be calculated in several ways: Optionally, a multi-stage trend analysis method can be used. First, the time window is divided into multiple sub-stages (e.g., 60 minutes is divided into four 15-minute stages), and the performance gradient for each stage is calculated separately. Then, a weighted average method is used to merge the gradients of each stage, giving higher weight to the more recent stage to highlight the latest trend changes. Finally, a gradient stability evaluation mechanism is established to calculate the variance of the gradient for each stage, and the confidence weight of the gradient is reduced when the variance is too large. Optionally, a nonlinear trend fitting method can also be used. First, multinomial regression or exponential fitting is used instead of linear regression for trend modeling, which can better capture the nonlinear characteristics of performance changes. Then, the derivative of the fitted curve at the current time point is calculated as the instantaneous change gradient, which more accurately reflects the latest trend. Finally, a trend prediction verification mechanism is established to verify the prediction accuracy of the trend model using historical data and dynamically adjust the model parameters and fitting method selection.
[0075] It is understandable that other methods can be used to calculate the performance change gradient, such as multi-scale trend decomposition based on wavelet transform or time series analysis using ARIMA model, etc., which are not limited here.
[0076] S206. The SMS gateway device predicts the probability of performance degradation of each supplier within a preset time window based on the performance change gradient.
[0077] The performance degradation probability refers to the likelihood that a supplier's performance will significantly decline within a preset time window. It represents the degree of risk of deterioration in the supplier's service quality, with a value ranging from 0 to 1. A higher value indicates a greater risk of degradation. For example, based on supplier A's current performance change gradient of -0.15, the predicted performance degradation probability within the next 30 minutes is 0.68, meaning there is a 68% chance of performance degradation.
[0078] Specifically, this step is executed immediately after the performance change gradient calculation in step S205 is completed. The SMS gateway device first establishes a performance degradation probability prediction model, which is built based on the statistical relationship between historical performance change gradients and actual performance degradation events. The SMS gateway device extracts a large number of performance gradient samples and corresponding actual performance change results within the time window from historical data to construct a training dataset for model calibration. The prediction model uses logistic regression to establish the mapping relationship between gradient values and degradation probabilities, calculated as: performance degradation probability = 1 / (1+e^(- ... (-α×性能变化梯度-β)), where α and β are model parameters trained using historical data. For suppliers with negative performance change gradients (indicating a performance decline trend), the SMS gateway device calculates the corresponding decay probability based on the absolute value of the gradient. A larger absolute gradient value indicates a more pronounced decline trend, and the corresponding decay probability is higher. For suppliers with positive performance change gradients or those close to zero, the SMS gateway device also performs probability calculations, but typically obtains a lower decay probability value. The SMS gateway device also considers the impact of the time window length on prediction accuracy, adjusting the prediction probability through a time decay function. A longer prediction time window increases prediction uncertainty. Finally, the SMS gateway device outputs the performance decay probability within the preset time window for each supplier.
[0079] In some embodiments, the probability of performance degradation can be predicted in several ways: Optionally, a machine learning ensemble prediction method can be used. First, multiple prediction models of different types (such as logistic regression, support vector machine, random forest, etc.) are trained to make predictions based on features such as performance gradient, historical degradation patterns, and external environmental factors. Then, an ensemble learning method (such as a voting mechanism or weighted averaging) is used to fuse the prediction results of multiple models to improve the accuracy and robustness of the prediction. Finally, a model performance evaluation mechanism is established to periodically verify the prediction accuracy of each model using new historical data and dynamically adjust the ensemble weight configuration. Optionally, a Bayesian probability update method can also be used. First, a basic degradation probability distribution for each supplier is established based on historical statistical data as a prior probability. Then, the current performance change gradient is used as new observational evidence, and the posterior distribution of the degradation probability is updated using the Bayesian formula. Finally, considering the individual differences of suppliers, personalized prediction model parameters are established for different suppliers to improve the targeting and accuracy of the prediction.
[0080] It is understandable that other methods can be used to predict the probability of performance degradation, such as time series prediction based on deep learning or state transition prediction using Markov chains, etc., which are not limited here.
[0081] S207. The SMS gateway device marks suppliers whose performance degradation probability is greater than a preset probability threshold as potential risk suppliers.
[0082] Specifically, this step is executed immediately after the performance degradation probability calculation in step S206 is completed. The SMS gateway device first reads the preset probability threshold parameter from its configuration. This threshold is typically set based on the business's level of risk control; a lower threshold (e.g., 0.3) represents a stricter risk control strategy, while a higher threshold (e.g., 0.7) represents a relatively lenient risk tolerance. Then, the SMS gateway device iterates through the performance degradation probability data of all suppliers, comparing each value with the preset probability threshold. For suppliers whose performance degradation probability exceeds the preset threshold, the SMS gateway device performs a risk marking operation: adding a potential risk identifier to the supplier status record, recording the marking timestamp and the degradation probability value that triggered the marking, and displaying the supplier's risk status in the SMS gateway device's monitoring panel with a special color or icon. The SMS gateway device also generates a risk warning log, recording in detail the identification process and related parameters of potential risk suppliers, including the current performance gradient, the basis for degradation probability calculation, and threshold comparison results, providing data support for subsequent risk analysis and decision optimization. For suppliers that do not reach the risk threshold, the SMS gateway device maintains their normal status identifier but continues performance monitoring and trend tracking. The entire labeling process also includes risk level classification. SMS gateway devices can set multiple risk levels (such as low risk 0.6-0.7, medium risk 0.7-0.8, and high risk above 0.8) based on the specific value of the attenuation probability, providing support for refined risk management.
[0083] S208, the SMS gateway device multiplies the comprehensive selection score of potential risky suppliers by a weighting factor.
[0084] The weighting factor is an adjustment parameter used to reduce the weight of potentially risky suppliers in the supplier selection process. Its value typically ranges from 0.1 to 0.9. For example, if supplier A is marked as a potentially risky supplier with an original overall preference score of 0.76, and the weighting factor is set to 0.7, the adjusted score would be 0.76 × 0.7 = 0.532, thus lowering the supplier's priority in the selection process.
[0085] Specifically, this step is executed immediately after the potential risk supplier marking in step S207 is completed, reducing the selection priority of high-risk suppliers through a scoring adjustment mechanism. The SMS gateway device first identifies all suppliers marked as potentially risky, retrieving their risk marking information and corresponding performance degradation probability values from the SMS gateway device's status record. Then, the SMS gateway device determines the corresponding weighting coefficient based on the risk level, which can be a fixed coefficient strategy (e.g., uniformly set to 0.7) or a dynamic coefficient strategy (calculating the corresponding weighting degree based on the magnitude of the degradation probability). The formula for calculating the dynamic weighting coefficient is: Weighting coefficient = 1 - α × (Performance degradation probability - Preset probability threshold), where α is the adjustment intensity parameter (usually set to 0.5-1.0). This formula ensures that suppliers with higher degradation probabilities receive a greater degree of weighting. Next, the SMS gateway device performs a scoring adjustment operation on each potential risk supplier, multiplying its comprehensive preferred score calculated in step S204 by the corresponding weighting coefficient to obtain the risk-adjusted comprehensive score. The SMS gateway device also records detailed information about the scoring adjustment, including the score before adjustment, the weighting coefficient, and the score after adjustment. The adjusted ratings will take effect during the supplier ranking and selection process, so that even if a supplier is currently performing well, its selection priority will be reduced if there is a high risk of performance degradation, thereby improving the foresight and stability of supplier switching decisions.
[0086] S209. The SMS gateway device will select the supplier with the highest comprehensive evaluation score and normal connection status as the optimal backup supplier.
[0087] In the above embodiments, the SMS gateway device further improves the accuracy of selecting the optimal backup supplier by introducing real-time performance monitoring and trend prediction.
[0088] However, in actual operation, the faulty suppliers that are switched off often regain their service capabilities after the fault is repaired. But the above embodiment lacks an active detection and evaluation mechanism for the recovery status of faulty suppliers, which may result in high-quality suppliers that have recovered being idle for a long time, resulting in a waste of resources.
[0089] In some embodiments, in order to further improve the resource utilization efficiency of the SMS gateway device, the following fault provider recovery method may be performed after the step of resubmitting the SMS request to be sent in the session channel of the best backup provider.
[0090] The following describes a faulty supplier recovery method according to an embodiment of this application: Please see Figure 3 This is a flowchart illustrating a fault supplier recovery method in an embodiment of this application.
[0091] S301. After detecting network connectivity of a faulty supplier, the SMS gateway device re-establishes a test connection based on the session template corresponding to the faulty supplier.
[0092] In this context, "failed provider" refers to an SMS service provider that was marked as unavailable during the previous failover process. "Network connectivity" indicates that the basic network connectivity at the TCP layer has been restored, enabling the establishment of underlying communication links. "Test connection" represents a temporary connection channel specifically used for provider recovery verification, distinct from formal business connections. For example, when the SMS gateway device detects that provider A, which was previously switched over due to a network failure, has regained network connectivity, it re-establishes a test connection using its corresponding session template parameters for recovery verification.
[0093] Specifically, the SMS gateway device continuously monitors the network status of all faulty providers through periodic network probing mechanisms (such as performing a ping test and TCP port connectivity check every 2 minutes). When it detects that the server address of a faulty provider is now reachable again and the port response is normal, it immediately initiates the recovery verification process. The SMS gateway device first queries the faulty provider database for detailed fault records of that provider, including the fault occurrence time, fault type, and fault duration. Then, it reads the complete connection configuration information corresponding to the faulty provider from the session template library, including key configuration items such as server IP address, port number, protocol version, authentication parameters, and transmission parameters. Next, the SMS gateway device creates a dedicated test connection instance and executes the complete connection establishment process using the parameters in the session template: first, it performs a TCP three-way handshake to establish a basic network connection, setting an appropriate connection timeout (e.g., 10 seconds) and retry mechanism; then, it performs a TLS handshake process according to the provider's security requirements to establish an encrypted communication channel; finally, it sends an SMPP binding request to complete the protocol layer session establishment, verifying the validity of the authentication parameters and the availability of the provider's services.
[0094] S302. The SMS gateway device sends a preset number of test SMS requests through the test connection.
[0095] Test SMS requests are simulated SMS sending requests specifically used to verify the recovery status of a provider. They contain standard SMS content, target numbers, and sending parameters but are not actually sent to the end user. For example, an SMS gateway device is configured with a preset limit of 20 requests. It sends 20 test SMS requests to the recovered provider A through a test connection to evaluate its current service processing capacity and response quality.
[0096] Specifically, the SMS gateway device first reads the preset test SMS quantity parameter from its configuration. This quantity is typically set based on business scale and testing accuracy requirements, ensuring both statistical reliability of the test results and avoiding excessive testing load on the supplier. Then, the SMS gateway device constructs standardized test SMS requests, including setting test-specific SMS content (e.g., System Recovery Test), using a reserved test mobile phone number as the target address, and configuring standard SMS sending parameters (e.g., priority, validity period). The SMS gateway device employs a batch sending strategy, sending the preset number of test SMS requests to the faulty supplier in batches via the test connection. A reasonable time interval (e.g., 100 milliseconds) is set between each batch to avoid impacting a newly recovered supplier with instantaneous high concurrency. During sending, the SMS gateway device assigns a unique identifier to each test request, records the sending timestamp, and sets a response timeout detection mechanism (e.g., 30-second timeout). Simultaneously, the SMS gateway device establishes a request status tracking mechanism to monitor the processing status of each test request in real time, including whether a supplier confirmation response has been received, the response time, and the returned status code. After all test requests are sent, the SMS gateway device waits for all responses to return or for timeouts to occur.
[0097] S303, SMS gateway device statistical test of SMS request success rate, average response time and connection stability indicators.
[0098] The connection stability metric refers to a quantitative indicator reflecting the stability of the test connection during the test, including a comprehensive evaluation value of dimensions such as the number of connection interruptions, reconnection success rate, and data transmission integrity. For example, if 20 test SMS requests are sent and 18 are successfully responded to, the success rate is 90%; the average time for a successful response is 150 milliseconds; and the connection remains uninterrupted during the test, the stability metric is 1.0.
[0099] Specifically, the SMS gateway device first aggregates the response results of all test requests, classifying the received responses according to status codes: successful responses (status code 0 or other codes indicating success), failed responses (various error status codes), and responses that timed out. Then, it calculates the success rate metric: counting the number of requests with successful responses, and using the formula Success Rate = Number of Successful Responses / Total Number of Requests Sent × 100%, it obtains the current service success rate percentage for the provider. Next, it calculates the average response time metric: extracting the response time data for all successful response requests (the time difference between the request sending timestamp and the received response timestamp), calculating the arithmetic mean to obtain the average response time, and simultaneously calculating the standard deviation, maximum, and minimum response times to provide data support for response stability assessment. Subsequently, the SMS gateway device analyzes connection stability metrics: statistically analyzing the number of connection interruptions during the test, the duration of each interruption, the number of reconnection attempts, and the success rate; checking the integrity of data transmission, including the integrity of request sending and response receiving; and calculating a comprehensive connection stability score using the formula Stability Index = (1 - Number of Interruptions / Preset Interruption Tolerance Threshold) × Data Integrity Coefficient × Reconnection Success Rate, ensuring that the stability metrics comprehensively reflect connection quality. Finally, the SMS gateway device records and stores the three key indicators, providing an accurate data foundation for subsequent recovery credibility score calculations.
[0100] S304. The SMS gateway device calculates a recovery reliability score based on success rate, average response time, and connection stability indicators.
[0101] The recovery reliability score is a comprehensive evaluation value calculated based on test results, reflecting the degree of recovery and service reliability of the faulty supplier. It is used to determine whether the supplier has fully restored its service capabilities. The value is usually between 0 and 1, with a higher value indicating greater recovery reliability. For example, based on test results such as a success rate of 90%, an average response time of 150ms, and a connection stability index of 1.0, the comprehensive calculation yields a recovery reliability score of 0.78, indicating that the supplier has a high recovery reliability.
[0102] Specifically, the SMS gateway device first performs standardized preprocessing on three core indicators, converting indicators with different dimensions into a unified scoring standard. For the success rate indicator, a percentage value is directly used as the scoring basis, with a maximum score of 1.0 corresponding to 100%. For the average response time indicator, an inverse proportional function is used for conversion, with the formula being: Response Time Score = Baseline Response Time / Actual Average Response Time, where the baseline response time is the ideal response time set by the SMS gateway device (e.g., 100 milliseconds). For the connection stability indicator, a standardized value in the 0-1 range is directly used. Then, the SMS gateway device establishes a recovery reliability score calculation model, using a weighted linear combination method to integrate the three standardized indicators. The calculation formula is: Recovery Reliability Score = w1 × Standardized Success Rate + w2 × Standardized Response Time Score + w3 × Standardized Stability Indicator, where w1, w2, and w3 are the weight coefficients for success rate, response time, and stability (e.g., 0.5, 0.3, 0.2), and the weight settings reflect the importance of different indicators in the recovery assessment. The SMS gateway device also performs credibility score correction processing: when the number of test samples is small, a sample confidence adjustment factor is introduced to reduce the confidence level of the score; when significant performance fluctuations are detected, a stability penalty factor is introduced to appropriately reduce the final score; when the supplier has excellent historical performance before the failure, a historical reputation weighting factor is introduced to appropriately increase the recovery score. Finally, the SMS gateway device outputs a recovery credibility score that has undergone comprehensive calculation and correction processing.
[0103] S305. When the recovery credibility score is greater than the preset credibility threshold, the SMS gateway device marks the status of the faulty supplier as available.
[0104] Specifically, the SMS gateway device first reads the preset trustworthiness threshold parameter from its configuration. This threshold is typically set based on the service quality requirements and risk tolerance of the business; a higher threshold (e.g., 0.8) represents a stricter recovery standard, while a lower threshold (e.g., 0.6) represents a more lenient recovery judgment. Then, the SMS gateway device compares the recovery trustworthiness score of the faulty supplier with the preset threshold. When the score exceeds the threshold, the status recovery process is triggered. The status recovery process includes several key steps: First, the supplier's status identifier in the SMS gateway device database is updated, changing the status field from faulty or unavailable to available, and recording the timestamp and triggering conditions of the status change. Then, the supplier's fault mark and related alarm information are cleared, restoring its normal display status in the monitoring panel. Next, the supplier is added back to the list of available suppliers, enabling it to participate in subsequent load balancing and backup supplier selection.
[0105] S306. The SMS gateway device downgrades the trust level of the faulty supplier based on the duration of the fault.
[0106] Specifically, this step is executed after the supplier's status is restored in step S305. It records and quantifies the impact of the fault on the supplier's long-term reputation through a trust level management mechanism. The SMS gateway device first calculates the fault duration by extracting the fault start timestamp and status restoration timestamp from the fault record database and calculating the time difference between them to obtain the accurate fault duration. Then, the SMS gateway device performs a trust level assessment based on the fault duration, establishing a mapping relationship between fault duration and trust level adjustment: short-term faults (e.g., 0-30 minutes) correspond to a slight downgrade, with the trust level decreasing by 1 level. Medium-term faults (e.g., 30 minutes-2 hours) correspond to a moderate downgrade, with the trust level decreasing by 2 levels. Long-term faults (e.g., over 2 hours) correspond to a severe downgrade, with the trust level decreasing by 3 levels or more. The SMS gateway device uses a multi-level classification system for trust levels, such as AAA (highest trust), AA (high trust), A (standard trust), B (general trust), and C (low trust), with each level corresponding to a different trust coefficient (e.g., AAA corresponds to 1.0, AA to 0.9, A to 0.8, etc.). Next, the SMS gateway device performs a trust level update operation: it queries the supplier's current trust level, determines the downgrade range based on the duration of the failure, and calculates the updated trust level. The new trust level is written to the supplier information database, and the time, reason, and basis for the level change are recorded. Simultaneously, the corresponding trust coefficient for the supplier is updated; this coefficient will be used as an adjustment factor in subsequent risk scoring calculations and supplier selection. The SMS gateway device also establishes a trust level recovery mechanism, gradually restoring the trust level through long-term stable and good performance, avoiding permanent adverse effects on the supplier from a single failure.
[0107] The above describes a session switching method for SMS sending failure in the embodiments of this application. The following describes an exemplary SMS gateway device 400 provided in the embodiments of this application.
[0108] Figure 4This is a schematic diagram of an exemplary hardware structure of the SMS gateway device 400 provided in an embodiment of this application. In some embodiments, the SMS gateway device 400 is a computer device, which includes a processor, a memory, and a network interface connected via an SMS gateway device bus. The processor of the computer device provides computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores operating SMS gateway devices, computer programs, and a database. The internal memory provides an environment for the operation of the operating SMS gateway devices and computer programs in the non-volatile storage medium. The database of the computer device stores data. The network interface of the computer device is used to communicate with other external terminals or SMS gateway devices via a network connection. In some embodiments, the network interface can be a wired network interface; in some embodiments, the network interface can also be a wireless network interface. When the computer program is executed by the processor, it implements a session switching method for SMS sending failures according to an embodiment of this application.
[0109] Those skilled in the art will understand that Figure 4 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0110] In some embodiments of this application, a computer-readable storage medium is also provided, including instructions that, when executed on the SMS gateway device 400, cause the SMS gateway device 400 to perform a session switching method for SMS sending failure according to an embodiment of this application.
[0111] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit it. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.
[0112] As used in the above embodiments, depending on the context, the term "when..." can be interpreted as meaning "if...", "after...", "in response to determining...", or "in response to detecting...". Similarly, depending on the context, the phrase "when determining..." or "if (the stated condition or event) is interpreted as meaning "if determining...", "in response to determining...", "when (the stated condition or event) is detected", or "in response to detecting (the stated condition or event)".
[0113] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state drive), etc.
[0114] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. This program can be stored in a computer-readable storage medium, and when executed, it can include the processes described in the above method embodiments. The aforementioned storage medium includes various media capable of storing program code, such as ROM or random access memory (RAM), magnetic disks, or optical disks.
Claims
1. A session switching method for SMS sending failure, characterized in that, The method, applied to an SMS gateway device, includes: When establishing SMPP sessions with various SMS providers, the SMS gateway device simultaneously constructs a session template library, which includes at least the protocol version, window size, and authentication parameters. The SMS gateway device calculates the fault risk score of each supplier based on the historical fault statistics of each supplier; When the current supplier starts sending SMS messages, the SMS gateway device selects the optimal backup supplier based on the fault risk score; The SMS gateway device pre-executes TCP connection and TLS handshake for the optimal backup supplier based on the session template corresponding to the optimal backup supplier, thereby obtaining a pre-warmed session channel; When a failure of the current supplier session is detected, the SMS gateway device performs SMPP binding and authentication verification based on the session template corresponding to the optimal backup supplier, and activates the preheating session channel into a complete SMPP session. The SMS gateway device resubmits the SMS request to be sent in the session channel of the optimal backup provider.
2. The method according to claim 1, characterized in that, The SMS gateway device calculates a fault risk score for each supplier based on historical fault statistics, specifically including: The SMS gateway device extracts the number of faults, fault duration, and fault recovery time of each supplier within a preset statistical period from historical logs to construct a supplier fault behavior dataset. The SMS gateway device calculates the fault frequency factor, persistence factor, and stability factor of each supplier based on the supplier fault behavior dataset. The fault frequency factor is the ratio of the number of fault occurrences to the preset statistical period. The persistence factor is the ratio of the average fault duration to the preset baseline time. The stability factor is the ratio of the maximum fault interval time to the minimum fault interval time. The SMS gateway device performs time-weighted processing on the fault frequency factor, the persistence factor, and the stability factor for different time periods based on a time decay function. The SMS gateway device performs a weighted summation of the weighted fault frequency factor, the persistence factor, and the stability factor according to preset weight coefficients to obtain a comprehensive fault risk score for each supplier.
3. The method according to claim 2, characterized in that, Before the step where the SMS gateway device performs time-weighted processing on the fault frequency factor, the persistence factor, and the stability factor for different time periods based on a time decay function, the method further includes: The SMS gateway device marks fault records whose fault duration is greater than the average historical fault duration of the corresponding supplier plus three times the standard deviation as abnormal fault records. The SMS gateway device counts the density of abnormal fault records within a preset time window; The SMS gateway device marks the preset time window where the density is greater than a preset density threshold as an abnormal fault accumulation period. When the abnormal fault clustering period is detected, the SMS gateway device calculates the environmental degradation coefficient based on the ratio of the number of abnormal fault records during the abnormal fault clustering period to the total number of fault records during the abnormal fault clustering period. The SMS gateway device performs numerical correction on all fault records within the abnormal fault aggregation period. The numerical correction is to divide the fault duration of all fault records within the abnormal fault aggregation period by the environmental degradation coefficient. The SMS gateway device merges the corrected fault records with the fault records from periods other than the abnormal fault aggregation period. The SMS gateway device recalculates the fault frequency factor, the persistence factor, and the stability factor based on the merged fault records of each supplier.
4. The method according to claim 1, characterized in that, When the current supplier starts sending SMS messages, the SMS gateway device selects the optimal backup supplier based on the fault risk score, specifically including: When the current supplier starts sending SMS messages, the SMS gateway device obtains the real-time operating status parameters of each supplier. The SMS gateway device calculates the performance score of each supplier based on the real-time operating status parameters. The performance score is inversely proportional to the number of connections and load rate of the supplier, and directly proportional to the response speed of the supplier. The SMS gateway device normalizes the fault risk scores and performance scores of each supplier to obtain standardized risk scores and standardized performance scores. The SMS gateway device performs a weighted summation of the standardized risk score and the standardized performance score based on preset risk weights and preset performance weights to obtain a comprehensive optimal score for each supplier. The SMS gateway device identifies the supplier with the highest comprehensive evaluation score and normal connection status as the optimal backup supplier.
5. The method according to claim 4, characterized in that, After the step of the SMS gateway device performing a weighted summation of the standardized risk score and the standardized performance score based on preset risk weights and preset performance weights to obtain the comprehensive optimal score for each supplier, the method further includes: The SMS gateway device calculates the performance change gradient based on the changing trends of SMS sending success rate and average response time of each supplier; The SMS gateway device predicts the probability of performance degradation of each supplier within a preset time window based on the performance change gradient. The SMS gateway device marks suppliers whose performance degradation probability is greater than a preset probability threshold as potential risk suppliers. The SMS gateway device multiplies the comprehensive selection score of the potential risk supplier by a weighting factor, which is determined based on the performance degradation probability.
6. The method according to claim 1, characterized in that, The SMS gateway device pre-executes TCP connection and TLS handshake for the optimal backup vendor based on the session template corresponding to the optimal backup vendor, thereby obtaining a pre-warmed session channel, specifically including: The SMS gateway device establishes a TCP socket connection based on the network address information of the optimal backup supplier, and sets the connection timeout and keep-alive parameters. The SMS gateway device initiates a TLS handshake negotiation based on the encryption configuration parameters in the session template corresponding to the optimal backup supplier, and obtains a warm-up session channel. After the TLS handshake is completed, the SMS gateway device sends an SMPP protocol capability probe message through an encrypted channel. The SMS gateway device adjusts the protocol version parameter and transmission window size parameter in the session template based on the response result of the SMPP protocol capability probe message.
7. The method according to claim 6, characterized in that, After the step of the SMS gateway device resubmitting the SMS request to be sent in the session channel of the optimal backup provider, the method further includes: After detecting network connectivity issues with the faulty supplier, the SMS gateway device re-establishes a test connection based on the session template corresponding to the faulty supplier. The SMS gateway device sends a preset number of test SMS requests through the test connection. The preset number is determined based on the average concurrent processing capacity of the faulty supplier before the failure. The SMS gateway device statistically analyzes the success rate, average response time, and connection stability index of the test SMS requests. The connection stability index is the ratio of the number of connection drops during the test to the test duration. The SMS gateway device calculates a recovery reliability score based on the success rate, the average response time, and the connection stability index. When the recovery credibility score is greater than a preset credibility threshold, the SMS gateway device marks the status of the faulty supplier as available. The SMS gateway device downgrades the trust level of the faulty supplier based on the duration of the fault. The trust level downgrade process involves applying a penalty coefficient to the fault risk score of the supplier within a preset observation period. The penalty coefficient is directly proportional to the duration of the fault.
8. A short message gateway device, characterized in that, The SMS gateway device includes: one or more processors and a memory; the memory is coupled to the one or more processors, the memory is used to store computer program code, the computer program code including computer instructions, and the one or more processors call the computer instructions to cause the SMS gateway device to perform the method as described in any one of claims 1-7.
9. A computer program product containing instructions, characterized in that, When the computer program product is run on the SMS gateway device, the SMS gateway device performs the method as described in any one of claims 1-7.
10. A computer-readable storage medium comprising instructions, characterized in that, When the instruction is executed on the SMS gateway device, the SMS gateway device performs the method as described in any one of claims 1-7.
Citation Information
Cited By
Multi-operator remote session path adaptive arrangement method, system, medium and device
CN121940345A
