SFTP service connection control method and device, equipment and storage medium
By listening and setting the number of sessions and channels, controlling the SFTP service connection, the server resource exhaustion caused by excessive client sessions and channels is solved, and the effective management of resources is achieved.
Patent Information
- Application Number
- CN202510731707.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-03
- Publication Date
- 2025-08-15
AI Technical Summary
When providing SFTP services, clients create too many sessions and channels that cause the platform's server resources to run out.
By listening to sessions and channels creation, counting the current number and setting a threshold, rejecting new sessions or channel creation that exceeds the threshold, preventing resource exhaustion.
It effectively prevents the number of channels created between the client and the platform from exceeding the standard, avoids the platform from creating excessive threads, and prevents the server resources from exhausting.
Smart Images

Figure CN120499253A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of financial technology, and in particular to an SFTP service connection control method, apparatus, device, and storage medium. Background Art
[0002] Financial applications such as bank-to-bank, bank-to-enterprise, and micro-gold require file reconciliation, so the platform provides an open API interface interaction mode in the form of files. This mode is implemented based on the SFTP protocol, and users can access files provided by the platform just like accessing local directories. Among them, service providers encapsulate their own services into a series of APIs and open them to third-party developers. This behavior is called open API, and the platform that provides open API is called platform. SFTP (Secure File Transfer Protocol) is a secure file transfer protocol implemented based on SSH (Secure Shell). It allows users to transfer files to remote servers in encrypted form to ensure file security.
[0003] The platform can provide SFTP services to clients based on the SFTP protocol. The SFTP service provides clients with services to establish sessions with the platform and channels within the sessions. A session is a secure connection between the client and the platform, representing a communication session between the client and the platform, and a channel is a channel for data transmission between the client and the platform.
[0004] Currently, when the platform provides SFTP services, clients can transmit data through channels created in sessions. Each channel created consumes one operating system thread of the platform. However, if the client creates too many sessions and / or channels, the platform will create too many operating system threads, thereby exhausting the platform's server resources. Summary of the Invention
[0005] In order to prevent the exhaustion of platform server resources, the present application provides an SFTP service connection control method, apparatus, device and storage medium.
[0006] In a first aspect, the present application provides an SFTP service connection control method, comprising:
[0007] In response to monitoring that the session is created, counting the number of current sessions;
[0008] In response to the number of current sessions exceeding a preset session number threshold, refusing to create a new session;
[0009] In response to the number of current sessions not exceeding a preset session number threshold, creating a channel; and in response to monitoring that the channel is created, counting the number of current channels;
[0010] In response to the current number of channels exceeding a preset channel number threshold, creation of a new channel is rejected.
[0011] Through the above implementation, the creation of sessions and channels is monitored. When it is determined that the current number of sessions exceeds the session number threshold, the creation of new sessions is stopped; when it is determined that the current number of channels exceeds the channel number threshold, the creation of new channels is stopped. In this way, the number of channels created between the client and the platform can be prevented from exceeding the limit, thereby preventing the platform from creating excessive threads and further preventing the platform's server resources from being exhausted.
[0012] Preferably, the present application provides an SFTP service connection control method, further comprising:
[0013] In response to the current number of channels not exceeding a preset channel number threshold, creating a new channel, and exchanging data with the client based on the new channel;
[0014] In response to the completion of the data interaction, the new channel is closed and the number of new current channels is counted.
[0015] Through the above implementation, when the current number of channels does not exceed the preset channel number threshold, it means that the platform still has sufficient resources to create a corresponding thread for the currently created fusion channel. After completing data transmission using the channel, the channel is closed. The platform can continue to use the resources released after the channel is closed to create a corresponding thread for the newly created channel.
[0016] Preferably, the present application provides an SFTP service connection control method, further comprising:
[0017] In response to monitoring that the session is closed, a new number of current sessions is counted.
[0018] Through the above implementation, after the session is closed, the new current session number is immediately re-counted, so that the platform can know the sessions that are actually in the connected state, so that the platform can calculate and determine whether the actual current session number exceeds the channel number threshold.
[0019] Preferably, after counting the number of new current sessions, the method further includes:
[0020] Clear the number of channels corresponding to the closed session and count the new number of current channels.
[0021] Through the above implementation, after the session is closed, the channels contained in the session will also be closed synchronously. At this time, the number of channels corresponding to the closed session is cleared, and the current number of channels is recounted. This helps the platform determine whether the actual current number of channels exceeds the channel number threshold.
[0022] Preferably, the present application provides an SFTP service connection control method, further comprising:
[0023] In response to detecting the session abnormality, closing the session.
[0024] Through the above implementation, after monitoring a session exception, the session is immediately closed, which can prevent the abnormal session from continuing to occupy platform resources and help the platform release more threads to serve newly created channels.
[0025] Preferably, after closing the session, the method further includes:
[0026] Count the number of new current sessions;
[0027] Clear the number of channels corresponding to the closed session and count the new number of current channels.
[0028] Through the above implementation, after closing a session, the number of current sessions is recounted, the number of channels corresponding to the closed session is cleared, and the number of current channels is recounted. Recounting the number of current sessions facilitates the platform to calculate and determine whether the actual number of current sessions exceeds the channel number threshold, and recounting the number of current channels helps the platform determine whether the actual number of current channels exceeds the channel number threshold.
[0029] In a second aspect, the present application provides an SFTP service connection control device, comprising:
[0030] A session number counting module is used to count the number of current sessions in response to monitoring the completion of session creation;
[0031] a session creation rejection module, configured to reject creation of a new session in response to the number of current sessions exceeding a preset session number threshold;
[0032] a channel number counting module, configured to create a channel in response to the current number of sessions not exceeding a preset session number threshold, and count the current number of channels in response to monitoring that the channel is created;
[0033] The channel creation rejection module is configured to reject creation of a new channel in response to the current number of channels exceeding a preset channel number threshold.
[0034] Through the above implementation, the creation of sessions and channels is monitored. When it is determined that the current number of sessions exceeds the session number threshold, the creation of new sessions is stopped; when it is determined that the current number of channels exceeds the channel number threshold, the creation of new channels is stopped. In this way, the number of channels created between the client and the platform can be prevented from exceeding the limit, thereby preventing the platform from creating excessive threads and further preventing the platform's server resources from being exhausted.
[0035] In a third aspect, the present application provides a computer device, which includes a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps in the above method when executing the computer program.
[0036] In a fourth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, which implements the steps in the above-mentioned method when executed by a processor.
[0037] In a fifth aspect, the present application further provides a computer program product, which includes a computer program that implements the steps of any of the above method embodiments when executed by a processor.
[0038] The above-mentioned SFTP service connection control method, apparatus, device, and storage medium, in response to monitoring the completion of session creation, counts the current number of sessions; in response to the current number of sessions exceeding a preset session number threshold, refuses to create a new session; in response to the current number of sessions not exceeding the preset session number threshold, creates a channel; in response to monitoring the completion of channel creation, counts the current number of channels; and in response to the current number of channels exceeding the preset channel number threshold, refuses to create a new channel. Through the above implementation, monitoring of session and channel creation is achieved. If it is determined that the current number of sessions exceeds the session number threshold, the creation of new sessions is stopped; if it is determined that the current number of channels exceeds the channel number threshold, the creation of new channels is stopped. In this way, the number of channels created between the client and the platform can be prevented from exceeding the limit, thereby preventing the platform from creating excessive threads and, in turn, preventing the platform from exhausting server resources.
[0039] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present application, nor is it intended to limit the scope of the present application. Other features of the present application will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments. It should be understood that the following drawings only illustrate certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can be obtained based on these drawings without paying any creative work.
[0041] Figure 1 This is a flow chart of an SFTP service connection control method provided in an embodiment of the present application;
[0042] Figure 2 This is a structural diagram of an SFTP service connection control device provided in an embodiment of the present application;
[0043] Figure 3 A schematic diagram of the structure of a computer device provided in an embodiment of the present application;
[0044] Figure 4 This is a diagram of the internal structure of a computer-readable storage medium provided in an embodiment of the present application. DETAILED DESCRIPTION
[0045] In order to make the purpose, technical solutions and advantages of the present disclosure more clearly understood, the present disclosure is further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present disclosure and are not intended to limit the present disclosure.
[0046] It should be noted that the terms "first," "second," and the like in the specification and claims herein and in the accompanying drawings are used to distinguish similar objects and are not necessarily used to describe a particular order or precedence. It should be understood that the terms used in this manner are interchangeable where appropriate so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having," as well as any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, apparatus, product, or device comprising a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units that are not explicitly listed or that are inherent to these processes, methods, products, or devices.
[0047] In this document, the term "and / or" simply describes a relationship between related objects, indicating that three possible relationships exist. For example, "A and / or B" could mean: A exists alone, A and B exist simultaneously, or B exists alone. Furthermore, the character " / " in this document generally indicates an "or" relationship between the related objects.
[0048] Example 1
[0049] Figure 1 This is a flow chart of an SFTP service connection control method provided in Example 1 of this application, refer to Figure 1 The method may be performed by a device for performing the method, and the device may be implemented by software and / or hardware. The method includes:
[0050] S110 : In response to monitoring that the session creation is completed, count the number of current sessions.
[0051] Among them, financial clients such as bank-to-bank, bank-to-enterprise, and micro-gold sometimes have scenarios where files need to be reconciled. To this end, the client needs to establish a secure communication connection with the platform, that is, the client needs to create a session with the platform. It should be noted that the service provider encapsulates its own services into a series of APIs and opens them up for use by third-party developers. This behavior is called an open API, and the platform that provides an open API is called a platform. After the session is established, if data needs to be transmitted between the client and the platform, a channel must be created under the session. The channel is used for data transmission between the client and the platform. The platform has a preset monitoring mechanism, which is used to monitor whether a session has been created. For example, after a session is created, a corresponding session creation completion signal will be generated. The monitoring mechanism determines whether a session has been created by judging whether a session creation completion signal has been generated.
[0052] It should be noted that since the platform has limited resources for creating threads to serve sessions or channels, the number of sessions that the platform can establish with clients is also limited. If the number of sessions is too large, the platform will be at risk of resource exhaustion. Therefore, it is necessary to count the number of existing sessions and record this number as the current number of sessions.
[0053] Specifically, each time the monitoring mechanism monitors a session creation completion signal, it counts the number of current sessions, which is the number of previous sessions plus 1.
[0054] S120: In response to the number of current sessions exceeding a preset session number threshold, refuse to create a new session.
[0055] It should be noted that since the platform has limited resources for creating threads to serve sessions or channels, it is necessary to ensure that the current number of sessions does not exceed the limit. To prevent the current number of sessions from exceeding the limit, the platform presets a session number threshold based on historical experience data. The session number threshold is used to compare with the current number of sessions to determine whether the current number of sessions exceeds the limit. If it is determined that the current number of sessions exceeds the preset session number threshold, it means that the platform no longer has sufficient resources to create threads for the channels in the session. At this time, if the client sends a new session creation request, the platform will refuse to create a new session.
[0056] S130: In response to the current number of sessions not exceeding a preset session number threshold, create a channel; in response to monitoring that the channel is created, count the current number of channels.
[0057] If the current number of sessions is determined to be less than the preset session number threshold, the platform has sufficient resources to create threads for the channels in the session. Therefore, after the session is created, a channel is further created under the session. It should be noted that the monitoring mechanism is also used to monitor whether the channel has been created. For example, after a channel is created, a corresponding channel creation completion signal is generated. The monitoring mechanism determines whether a channel creation completion signal has been generated, thereby determining whether the channel has been created. If a channel creation completion signal is detected, the channel has been created.
[0058] It should be noted that since the platform resources used to create threads for session or channel services are limited, it is necessary to ensure that the number of current channels does not exceed the limit. To this end, it is necessary to count the number of channels at the current moment and record this number as the current number of channels.
[0059] S140: In response to the current number of channels exceeding a preset channel number threshold, refuse to create a new channel.
[0060] It should be noted that in order to prevent the current number of channels from exceeding the limit, the platform presets a channel number threshold based on historical experience data; the channel number threshold is used to compare with the current number of channels to determine whether the current number of channels exceeds the limit; if the current number of channels exceeds the preset channel number threshold, it means that the current number of channels exceeds the limit, which means that the platform no longer has sufficient resources to provide processes for newly created channels; at this time, if the client submits an application to create a new channel, the platform will refuse to create the new channel.
[0061] It should be noted that this embodiment, in response to monitoring the completion of session creation, counts the current number of sessions; in response to the current number of sessions exceeding a preset session number threshold, refuses to create a new session; in response to the current number of sessions not exceeding the preset session number threshold, creates a channel; in response to monitoring the completion of channel creation, counts the current number of channels; in response to the current number of channels exceeding the preset channel number threshold, refuses to create a new channel. Through the above implementation, monitoring of session and channel creation is achieved. If it is determined that the current number of sessions exceeds the session number threshold, the creation of new sessions is stopped; if it is determined that the current number of channels exceeds the channel number threshold, the creation of new channels is stopped. In this way, the number of channels created between the client and the platform can be prevented from exceeding the limit, thereby preventing the platform from creating excessive threads and, in turn, preventing the platform from exhausting server resources.
[0062] Example 2
[0063] A second embodiment of the present application provides a method for controlling an SFTP service connection, which supplements the method described in the first embodiment. It should be noted that for portions not described in detail in this embodiment, reference may be made to the descriptions in other embodiments. The method includes:
[0064] S210 : In response to monitoring that the session creation is completed, count the number of current sessions.
[0065] S220: In response to the number of current sessions exceeding a preset session number threshold, refuse to create a new session.
[0066] S230: In response to the current number of sessions not exceeding a preset session number threshold, create a channel; in response to monitoring that the channel is created, count the current number of channels.
[0067] S240: In response to the current number of channels exceeding a preset channel number threshold, refuse to create a new channel.
[0068] S250: In response to the current number of channels not exceeding a preset channel number threshold, create a new channel, and exchange data with the client based on the new channel.
[0069] Among them, if it is determined that the current number of channels does not exceed the preset channel number threshold, it means that the platform has sufficient resources to create threads for the channels in the session. At this time, a new channel is created in the session between the client and the platform, and the new channel is used to interact with the client for data.
[0070] S260: In response to the completion of the data interaction, close the new channel and count the new number of current channels.
[0071] Among them, in order to save the platform's thread resources, after a channel completes data interaction, the channel is immediately closed and the thread responsible for the channel is released; afterwards, in order to facilitate the platform to determine whether the current actual number of channels exceeds the standard, it is necessary to count the new current number of channels at the current moment.
[0072] It should be noted that, through the above implementation, when the current number of channels does not exceed the preset channel number threshold, it means that the platform still has sufficient resources to create corresponding threads for the currently created fusion channel. After completing data transmission using the channel, the channel is closed. The platform can continue to use the resources released after the channel is closed to create corresponding threads for the newly created channel.
[0073] Example 3
[0074] A third embodiment of the present application provides a method for controlling an SFTP service connection, which supplements the method described in the first embodiment. It should be noted that for portions not described in detail in this embodiment, reference may be made to the descriptions in other embodiments. The method includes:
[0075] S310 : In response to monitoring that the session creation is completed, count the number of current sessions.
[0076] S320: In response to the number of current sessions exceeding a preset session number threshold, refuse to create a new session.
[0077] S330: In response to the current number of sessions not exceeding a preset session number threshold, create a channel; in response to monitoring that the channel is created, count the current number of channels.
[0078] S340: In response to the current number of channels exceeding a preset channel number threshold, refuse to create a new channel.
[0079] S350: In response to monitoring that the session is closed, count the number of new current sessions.
[0080] The monitoring mechanism is also used to monitor whether a session is closed. For example, if a session is closed, a corresponding session closing signal will be generated. The monitoring mechanism determines whether the session is closed by monitoring whether the session closing signal exists.
[0081] It should be noted that when all channels in a session have completed data transmission, the session is no longer necessary. In order to save platform thread resources, the session needs to be closed, that is, the communication connection between the client and the platform related to the session is disconnected.
[0082] It should be noted that, through the above implementation, after the session is closed, the new current session number is immediately recounted, so that the platform can know the sessions that are actually in the connected state, so that the platform can calculate and determine whether the actual current session number exceeds the channel number threshold.
[0083] Example 4
[0084] A fourth embodiment of the present application provides a method for controlling an SFTP service connection, which supplements the method described in the third embodiment. It should be noted that for portions not described in detail in this embodiment, reference may be made to the descriptions in other embodiments. The method includes:
[0085] S410: In response to monitoring that the session creation is completed, count the number of current sessions.
[0086] S420: In response to the number of current sessions exceeding a preset session number threshold, refuse to create a new session.
[0087] S430: In response to the current number of sessions not exceeding a preset session number threshold, a channel is created; in response to monitoring that the channel creation is completed, the current number of channels is counted.
[0088] S440: In response to the current number of channels exceeding a preset channel number threshold, refuse to create a new channel.
[0089] S450: In response to monitoring that the session is closed, count the number of new current sessions.
[0090] S460: Clear the number of channels corresponding to the closed session and count the new number of current channels.
[0091] It should be noted that after monitoring the closing of a session, the current number of sessions still includes the number of channels related to the closed session. For example, when monitoring the closing of a session, the current number of channels is 100, and the number of channels related to the closed session is 10. The actual number of current channels is 90. Obviously, the current number of channels is not accurate. Therefore, it is necessary to clear the number of channels corresponding to the closed session and then re-count the actual number of channels at the current moment to obtain a new current number of channels.
[0092] It should be noted that after the session is closed, the channels contained in the session will also be closed synchronously. At this time, clearing the number of channels corresponding to the closed session and re-counting the current number of channels will help the platform determine whether the actual current number of channels exceeds the channel number threshold.
[0093] Example 5
[0094] A fifth embodiment of the present application provides a method for controlling an SFTP service connection, which supplements the method described in the first embodiment. It should be noted that for portions not described in detail in this embodiment, reference may be made to the descriptions in other embodiments. The method includes:
[0095] S510: In response to monitoring that a session is created, count the number of current sessions.
[0096] S520: In response to the number of current sessions exceeding a preset session number threshold, refuse to create a new session.
[0097] S530: In response to the current number of sessions not exceeding a preset session number threshold, create a channel; in response to monitoring that the channel is created, count the current number of channels.
[0098] S540: In response to the current number of channels exceeding a preset channel number threshold, refuse to create a new channel.
[0099] S550: In response to detecting the session abnormality, close the session.
[0100] Among them, session abnormalities may be caused by reasons such as network fluctuations, session ID abnormalities, and data storage mechanism abnormalities. It should be noted that if a session abnormality occurs, the session can no longer be used, but the abnormal session will still occupy the platform's thread resources. In order to save the platform's thread resources, the session can be monitored through a monitoring mechanism to determine whether the session has an abnormality. If it is determined that the session has an abnormality, the session will be closed immediately, that is, the communication connection between the client and the platform related to the session will be disconnected.
[0101] It should be noted that, through the above implementation, after a session exception is detected, the session is immediately closed, which can prevent the abnormal session from continuing to occupy platform resources and help the platform release more threads to serve newly created channels.
[0102] Example 6
[0103] A sixth embodiment of the present application provides a method for controlling an SFTP service connection, which supplements the method described in the fifth embodiment. It should be noted that for portions not described in detail in this embodiment, reference may be made to the descriptions in other embodiments. The method includes:
[0104] S610: In response to monitoring that a session is created, count the number of current sessions.
[0105] S620: In response to the number of current sessions exceeding a preset session number threshold, refuse to create a new session.
[0106] S630: In response to the current number of sessions not exceeding a preset session number threshold, create a channel; in response to monitoring that the channel is created, count the current number of channels.
[0107] S640: In response to the current number of channels exceeding a preset channel number threshold, refuse to create a new channel.
[0108] S650: In response to detecting the session abnormality, close the session.
[0109] S660: Count the number of new current sessions.
[0110] When a session is closed, the current session count still includes the closed session, which means that the current session count is not accurate. In order to make the platform understand the actual number of sessions, it is necessary to re-count the number of sessions to obtain a new current session count.
[0111] S670: Clear the number of channels corresponding to the closed session and count the new number of current channels.
[0112] When a session is closed, the number of channels corresponding to the closed session is still included in the current number of channels. That is, the current number of channels is not the actual number of channels. In this case, you need to clear the number of channels corresponding to the closed session immediately after the session is closed and re-count the current number of channels to obtain the new current number of channels.
[0113] It should be noted that, through the above implementation, after closing the session, the current number of sessions is recounted, the number of channels corresponding to the closed session is cleared, and the current number of channels is recounted; recounting the current number of sessions facilitates the platform to calculate and determine whether the actual number of current sessions exceeds the channel number threshold, and recounting the current number of channels helps the platform determine whether the actual number of current channels exceeds the channel number threshold.
[0114] It should be understood that, although the various steps in the flowcharts involved in the various embodiments described above are displayed in sequence according to the instructions of the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and these steps can be executed in other orders. Moreover, at least a portion of the steps in the flowcharts involved in the various embodiments described above can include multiple steps or multiple stages, and these steps or stages are not necessarily executed and completed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a portion of steps or stages in other steps.
[0115] Example 7
[0116] Based on the same inventive concept, this embodiment also provides an SFTP service connection control device for implementing the aforementioned SFTP service connection control method. The solution provided by this device is similar to the solution described in the aforementioned method. Therefore, the specific limitations in one or more of the following embodiments of the SFTP service connection control device can be found in the above-described limitations of the SFTP service connection control method and are not further elaborated here.
[0117] In this embodiment, Figure 2 As shown, an SFTP service connection control device is provided, including:
[0118] A session number counting module is used to count the number of current sessions in response to monitoring the completion of session creation;
[0119] a session creation rejection module, configured to reject creation of a new session in response to the number of current sessions exceeding a preset session number threshold;
[0120] a channel number counting module, configured to create a channel in response to the current number of sessions not exceeding a preset session number threshold, and count the current number of channels in response to monitoring that the channel is created;
[0121] The channel creation rejection module is configured to reject creation of a new channel in response to the current number of channels exceeding a preset channel number threshold.
[0122] Each module in the aforementioned SFTP service connection control device may be implemented in whole or in part through software, hardware, or a combination thereof. Each module may be embedded in or independent of a processor in a computer device in the form of hardware, or may be stored in a memory in the computer device in the form of software, so that the processor can call and execute the corresponding operations of each module.
[0123] It should be noted that this embodiment, in response to monitoring the completion of session creation, counts the current number of sessions; in response to the current number of sessions exceeding a preset session number threshold, refuses to create a new session; in response to the current number of sessions not exceeding the preset session number threshold, creates a channel; in response to monitoring the completion of channel creation, counts the current number of channels; and in response to the current number of channels exceeding the preset channel number threshold, refuses to create a new channel. Through the above implementation, monitoring of session and channel creation is achieved. If it is determined that the current number of sessions exceeds the session number threshold, the creation of new sessions is stopped; if it is determined that the current number of channels exceeds the channel number threshold, the creation of new channels is stopped. In this way, the number of channels created between the client and the platform can be prevented from exceeding the limit, thereby preventing the platform from creating excessive threads and, in turn, preventing the platform from exhausting server resources.
[0124] In an optional embodiment, the SFTP service connection control device further includes:
[0125] a data interaction module, configured to create a new channel in response to the current number of channels not exceeding a preset channel number threshold, and to exchange data with the client based on the new channel;
[0126] The channel re-counting module is configured to close the new channel and count the new number of current channels in response to the completion of the data interaction.
[0127] In an optional embodiment, the SFTP service connection control device further includes:
[0128] The session re-statistics module is configured to count the number of new current sessions in response to monitoring that the session is closed.
[0129] In an optional embodiment, the SFTP service connection control device further includes:
[0130] The channel number clearing module is used to clear the channel number corresponding to the closed session and count the new current channel number.
[0131] In an optional embodiment, the SFTP service connection control device further includes:
[0132] The abnormal session closing module is used to close the session in response to detecting the abnormality of the session.
[0133] In an optional embodiment, the SFTP service connection control device further includes:
[0134] Session statistics module, used to count the number of new current sessions;
[0135] The channel statistics module is used to clear the number of channels corresponding to the closed sessions and count the new current number of channels.
[0136] Example 8
[0137] In this embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 3As shown. The computer device includes a processor, a memory, and a network interface connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and computer program in the non-volatile storage medium. The database of the computer device is used to store data. The network interface of the computer device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, it implements an SFTP service connection control method.
[0138] Those skilled in the art will understand that Figure 3 The structure shown in the figure is merely a block diagram of a portion of the structure related to the solution of the present disclosure, and does not constitute a limitation on the computer device to which the solution of the present disclosure is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.
[0139] Example 9
[0140] In this embodiment, a computer readable storage medium is provided. Figure 4 As shown, a computer program is stored thereon, and when the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.
[0141] Example 10
[0142] In this embodiment, a computer program product is provided, including a computer program. When the computer program is executed by a processor, the steps in the above method embodiments are implemented.
[0143] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this disclosure are all information and data authorized by the user or fully authorized by all parties.
[0144] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, database or other media used in the embodiments provided in the present disclosure may include at least one of non-volatile and volatile memory. Non-volatile memory may include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory may include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this disclosure may include at least one of a relational database and a non-relational database. Non-relational databases may include, but are not limited to, distributed databases based on blockchains. The processor involved in each embodiment provided in this disclosure may be, but are not limited to, a general-purpose processor, a central processing unit, a graphics processing unit, a digital signal processor, a programmable logic unit, a data processing logic unit based on quantum computing, etc.
[0145] The technical features of the above embodiments can be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0146] The above-described embodiments merely represent several implementation methods of the present disclosure. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present disclosure. It should be noted that a person of ordinary skill in the art may make various modifications and improvements without departing from the spirit of the present disclosure, all of which fall within the scope of protection of the present disclosure. Therefore, the scope of protection of the present disclosure shall be determined by the appended claims.
Claims
1. A method for controlling an SFTP service connection, characterized in that: include: In response to monitoring that the session is created, counting the number of current sessions; In response to the number of current sessions exceeding a preset session number threshold, refusing to create a new session; In response to the number of current sessions not exceeding a preset session number threshold, creating a channel; and in response to monitoring that the channel is created, counting the number of current channels; In response to the current number of channels exceeding a preset channel number threshold, creation of a new channel is rejected.
2. The method according to claim 1, characterized in that Also includes: In response to the current number of channels not exceeding a preset channel number threshold, creating a new channel, and exchanging data with the client based on the new channel; In response to the completion of the data interaction, the new channel is closed and the number of new current channels is counted.
3. The method according to claim 1, characterized in that Also includes: In response to monitoring that the session is closed, a new number of current sessions is counted.
4. The method according to claim 3, characterized in that After counting the number of new current sessions, the method further includes: Clear the number of channels corresponding to the closed session and count the new number of current channels.
5. The method according to claim 1, wherein Also includes: In response to detecting the session abnormality, closing the session.
6. The method according to claim 5, characterized in that After closing the session, the method further includes: Count the number of new current sessions; Clear the number of channels corresponding to the closed session and count the new number of current channels.
7. An SFTP service connection control device, characterized in that: The device comprises: A session number counting module is used to count the number of current sessions in response to monitoring the completion of session creation; a session creation rejection module, configured to reject creation of a new session in response to the number of current sessions exceeding a preset session number threshold; a channel number counting module, configured to create a channel in response to the current number of sessions not exceeding a preset session number threshold, and count the current number of channels in response to monitoring that the channel is created; The channel creation rejection module is configured to reject creation of a new channel in response to the current number of channels exceeding a preset channel number threshold.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.