CN112637121B - Data port updating method and device, electronic equipment and readable storage medium - Google Patents

Data port updating method and device, electronic equipment and readable storage medium Download PDF

Info

Publication number
CN112637121B
CN112637121B CN202011285062.3A CN202011285062A CN112637121B CN 112637121 B CN112637121 B CN 112637121B CN 202011285062 A CN202011285062 A CN 202011285062A CN 112637121 B CN112637121 B CN 112637121B
Authority
CN
China
Prior art keywords
port
local server
communication
http
browser
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202011285062.3A
Other languages
Chinese (zh)
Other versions
CN112637121A (en
Inventor
刘军
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China Citic Bank Corp Ltd
Original Assignee
China Citic Bank Corp Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by China Citic Bank Corp Ltd filed Critical China Citic Bank Corp Ltd
Priority to CN202011285062.3A priority Critical patent/CN112637121B/en
Publication of CN112637121A publication Critical patent/CN112637121A/en
Application granted granted Critical
Publication of CN112637121B publication Critical patent/CN112637121B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/02Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • H04L67/141Setup of application sessions
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • H04L67/142Managing session states for stateless protocols; Signalling session states; State transitions; Keeping-state mechanisms
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/16Implementation or adaptation of Internet protocol [IP], of transmission control protocol [TCP] or of user datagram protocol [UDP]
    • H04L69/161Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields
    • H04L69/162Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields involving adaptations of sockets based mechanisms

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer And Data Communications (AREA)

Abstract

The embodiment of the application provides a method and a device for updating a data port, electronic equipment and a readable storage medium. The method comprises the following steps: when the browser establishes communication with a local server through a first http port, determining whether the communication condition of the first http port meets a preset reconnection condition; and if so, the browser end sends an update request for the first http port to the local server end in a Websocket mode, so that the local server end updates the port for establishing communication between the browser end and the local server end to the second http port based on the update request. Based on the scheme, when the communication between the browser end and the local server end cannot be established through the first http port, the communication port is distributed again in a Websocket communication mode, the first http port is updated, and a foundation is provided for establishing normal communication between the browser end and the local server end through the updated communication port.

Description

Data port updating method and device, electronic equipment and readable storage medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method and an apparatus for updating a data port, an electronic device, and a readable storage medium.
Background
At present, a browser end and a plurality of pass-through ports establish communication with a local server end, so that the browser end can access local resources of a client through the local server end.
In actual use, there may be a situation that a port between a browser end and a local server end is occupied or disabled, in the prior art, many ports (generally 5 to 10 ports) are reserved, polling is performed in the reserved ports, and an available port is determined for communication, but once all the reserved ports are unavailable, normal communication between the browser end and the local server end is affected.
Disclosure of Invention
The present application aims to solve at least one of the above technical drawbacks. The technical scheme adopted by the application is as follows:
in a first aspect, an embodiment of the present application provides a method for updating a data port, where the method includes:
when the browser establishes communication with a local server through a first http port, determining whether the communication condition of the first http port meets a preset reconnection condition;
if the first http port is satisfied, the browser end sends an update request for the first http port to the local server end in a Websocket manner, so that the local server end updates a port for establishing communication between the browser end and the local server end to the second http port based on the update request.
Optionally, the method further includes:
and the browser end establishes communication with the local server end through the second http port.
When the communication with the local server is established through the second http port, if the communication condition of the second http port satisfies the reconnection condition, the method further includes:
and taking the second http port as the first http port, repeatedly executing the browser to send an update request for the first http port to the local server in a Websocket manner, so that the local server updates the port for establishing communication between the browser and the local server to the second http port based on the update request, and establishing communication between the browser and the local server through the second http port until a preset stop condition is met.
Optionally, the reconnect condition comprises at least one of:
all the ports in the first http port or the second http port fail to establish communication;
all the ports in the first http port or the second http port cannot establish communication within a preset time.
Optionally, the stop condition comprises:
the repeated execution times reach the preset times.
Optionally, the local server updates the port for establishing communication between the browser side and the local server side to the second http port based on the update request, by:
and the local server updates the port for establishing the communication between the browser terminal and the local server terminal into a second http port based on the port information of the second http port carried by the update request.
Optionally, the sending, by the browser, an update request for the first http port to the local server in a Websocket manner includes:
determining whether the browser end supports Websocket;
and if the request is supported, the browser end sends an update request for the first http port to the local server end in a Websocket mode.
In a second aspect, an embodiment of the present application provides another method for updating a data port, where the method includes:
when a browser establishes communication with a local server through a first Websocket port, determining whether the communication condition of the first Websocket port meets a preset reconnection condition;
if the first Websocket port is met, the browser side sends an updating request for the first Websocket port to the local server side in an http mode, so that the local server side updates a port for establishing communication between the browser side and the local server side to be the second Websocket port based on the updating request.
Optionally, the method further includes:
and the browser end establishes communication with the local server end through the second Websocket port.
Optionally, when the browser establishes communication with the local server through the second Websocket port, if the communication condition of the second Websocket port meets the reconnection condition, the method further includes:
and taking the second Websocket port as the first Websocket port, repeatedly executing the browser to send an updating request for the first Websocket port to the local server in an http mode, so that the local server updates the port for establishing communication between the browser and the local server to the second Websocket port based on the updating request, and establishing communication between the browser and the local server through the second Websocket port until a preset stopping condition is met.
Optionally, the reconnect condition comprises at least one of:
all ports in the first Websocket port or the second Websocket port fail to establish communication;
all the ports in the first Websocket port or the second Websocket port cannot establish communication within a preset time length.
Optionally, the stop condition comprises:
the repeated execution times reach the preset times.
Optionally, the local server updates a port for establishing communication between the browser and the local server to the second Websocket port based on the update request, and by the following means:
and the local server updates the port for establishing the communication between the browser and the local server to be the second Websocket port based on the port information of the second Websocket port carried by the update request.
Optionally, the sending, by the browser side, an update request for the first Websocket port to the local server side through http, includes:
determining whether the browser side supports http;
and if the first Websocket port is supported, the browser side sends an update request for the first Websocket port to the local server side in an http mode.
In a third aspect, an embodiment of the present application provides an apparatus for updating a data port, where the apparatus includes:
the communication condition monitoring module is used for determining whether the communication condition of the first http port meets a preset reconnection condition when the browser establishes communication with the local server through the first http port;
and the port updating module is used for sending an updating request for the first http port to the local server in a Websocket mode when the communication condition of the first http port meets a preset reconnection condition, so that the local server updates the port for establishing the communication between the browser and the local server to a second http port based on the updating request.
Optionally, the apparatus further comprises:
and the communication establishing module is used for establishing communication between the browser end and the local server end through the second http port.
Optionally, the communication establishing module is further configured to:
when the communication between the browser and the local server is established through the second http port, if the communication condition of the second http port meets the reconnection condition, the second http port is used as the first http port, the browser repeatedly executes the step of sending an update request for the first http port to the local server through the Websocket so that the local server updates a port for establishing the communication between the browser and the local server to the second http port based on the update request, and the browser establishes the communication with the local server through the second http port until the preset stop condition is met.
Optionally, the reconnect condition comprises at least one of:
all the ports in the first http port or the second http port fail to establish communication;
all the ports in the first http port or the second http port cannot establish communication within a preset time period.
Optionally, the stop condition comprises:
the repeated execution times reach the preset times.
Optionally, the local server updates a port for establishing communication between the browser and the local server to the second http port based on the update request, by:
and the local server updates the port for establishing the communication between the browser terminal and the local server terminal into a second http port based on the port information of the second http port carried by the update request.
Optionally, when the browser sends an update request for the first http port to the local server in a Websocket manner, the port update module is specifically configured to:
determining whether the browser end supports Websocket;
and if the request is supported, the browser end sends an update request for the first http port to the local server end in a Websocket mode.
In a fourth aspect, an embodiment of the present application provides another apparatus for updating a data port, where the apparatus includes:
the communication condition monitoring module is used for determining whether the communication condition of the first Websocket port meets a preset reconnection condition or not when the browser establishes communication with the local server through the first Websocket port;
and the port updating module is used for sending an updating request for the first Websocket port to the local server in an http mode when the communication condition of the first Websocket port meets a preset reconnection condition, so that the local server updates the port for establishing the communication between the browser and the local server to be a second Websocket port based on the updating request.
Optionally, the apparatus further comprises:
and the communication establishing module is used for establishing communication between the browser end and the local server end through the second Websocket port.
Optionally, the communication establishing module is further configured to:
when the browser establishes communication with the local server through the second Websocket port, if the communication condition of the second Websocket port meets a reconnection condition, the second Websocket port is used as the first Websocket port, the browser repeatedly executes the step that the browser sends an updating request for the first Websocket port to the local server in an http mode, so that the local server updates the port used for establishing communication between the browser and the local server to the second Websocket port based on the updating request, and the browser establishes communication with the local server through the second Websocket port until the preset stopping condition is met.
Optionally, the reconnect condition comprises at least one of:
all ports in the first Websocket port or the second Websocket port fail to establish communication;
all ports in the first Websocket port or the second Websocket port cannot establish communication within a preset time length.
Optionally, the stop condition comprises:
the repeated execution times reach the preset times.
Optionally, the local server updates a port for establishing communication between the browser and the local server to the second Websocket port based on the update request, and by the following means:
and the local server updates the port for establishing the communication between the browser end and the local server end into a second Websocket port based on the port information of the second Websocket port carried by the update request.
Optionally, when the browser sends an update request for the first Websocket port to the local server in an http manner, the port update module is specifically configured to:
determining whether the browser side supports http;
and if the first Websocket port is supported, the browser side sends an update request for the first Websocket port to the local server side in an http mode.
In a fifth aspect, an embodiment of the present application provides an electronic device, including: a processor and a memory;
a memory for storing operating instructions;
a processor, configured to execute the method for updating a data port as shown in any implementation manner of the first aspect to the second aspect of the present application by calling an operation instruction.
In a sixth aspect, the present application provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the method for updating a data port shown in any one of the implementation manners of the first aspect to the second aspect of the present application.
The technical scheme provided by the embodiment of the application has the following beneficial effects:
according to the scheme provided by the embodiment of the application, when the browser end establishes communication with the local server end through the first http port, if the communication condition of the first http port meets the preset reconnection condition, the browser end sends the update request for the first http port to the local server end in a Websocket mode, so that the local server end updates the port for establishing communication between the browser end and the local server end to the second http port based on the update request. Based on the scheme, when the communication between the browser end and the local server end cannot be established through the first http port, the communication port can be distributed again in a Websocket communication mode, the first http port is updated, and a foundation is provided for establishing normal communication between the browser end and the local server end through the updated communication port.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings used in the description of the embodiments of the present application will be briefly described below.
Fig. 1 is a schematic flowchart of a method for updating a data port according to an embodiment of the present disclosure;
fig. 2 is a schematic flowchart of a specific implementation of a method for updating a data port according to an embodiment of the present application;
fig. 3 is a schematic flowchart of another data port updating method according to an embodiment of the present disclosure;
fig. 4 is a schematic structural diagram of an update apparatus of a data port according to an embodiment of the present application;
fig. 5 is a schematic structural diagram of another data port update apparatus according to an embodiment of the present disclosure;
fig. 6 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
Reference will now be made in detail to embodiments of the present application, examples of which are illustrated in the accompanying drawings, wherein like or similar reference numerals refer to the same or similar elements or elements having the same or similar function throughout. The embodiments described below with reference to the drawings are exemplary only for the purpose of explaining the present application and are not to be construed as limiting the present invention.
As used herein, the singular forms "a", "an", "the" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will be further understood that the terms "comprises" and/or "comprising," when used in this specification, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof. It will be understood that when an element is referred to as being "connected" or "coupled" to another element, it can be directly connected or coupled to the other element or intervening elements may also be present. Further, "connected" or "coupled" as used herein may include wirelessly connected or wirelessly coupled. As used herein, the term "and/or" includes all or any element and all combinations of one or more of the associated listed items.
To make the objects, technical solutions and advantages of the present application more clear, embodiments of the present application will be described in further detail below with reference to the accompanying drawings.
The following describes the technical solutions of the present application and how to solve the above technical problems with specific embodiments. The following several specific embodiments may be combined with each other, and details of the same or similar concepts or processes may not be repeated in some embodiments. Embodiments of the present application will be described below with reference to the accompanying drawings.
Fig. 1 shows a schematic flowchart of a method for updating a data port according to an embodiment of the present application, where as shown in fig. 1, the method mainly includes:
step S110, when the browser establishes communication with a local server through a first http port, determining whether the communication condition of the first http port meets a preset reconnection condition;
and S120, if so, the browser sends an update request for the first http port to the local server in a Websocket mode, so that the local server updates the port for establishing communication between the browser and the local server to a second http port based on the update request.
In this embodiment of the application, the first http port may be a communication interface pre-established between the browser end and the local service end in a local http manner.
In the embodiment of the application, when the browser end establishes communication with the local server end through the first http port, the browser end may poll each first http port in sequence, and if it is determined that the communication condition of each first http port satisfies the preset reconnection condition, it may be considered that the communication between the browser end and the local server end cannot be established through the first http port.
In practical use, the reconnection condition may include that all the first http ports fail to establish communication, or that all the first http ports fail to establish communication within a preset time period.
The number of the ports of the first http ports and the preset duration are selected to consider user experience, the number of the ports of the first http ports is suggested to be 5-10, and the preset duration is less than 2 seconds.
In the embodiment of the application, when the communication condition of each first http port meets the preset reconnection condition, the communication ports can be distributed again in a Websocket communication mode, specifically, the browser side can send an update request for the first http port to the local server side in the Websocket mode, and the local server side updates the port for establishing the communication between the browser side and the local server side to the second http port based on the update request.
According to the method provided by the embodiment of the application, when the browser end establishes communication with the local server end through the first http port, if the communication condition of the first http port meets the preset reconnection condition, the browser end sends an update request for the first http port to the local server end in a Websocket mode, so that the local server end updates a port for establishing communication between the browser end and the local server end to the second http port based on the update request. Based on the scheme, when the communication between the browser end and the local server end cannot be established through the first http port, the communication port is distributed again in a Websocket communication mode, the first http port is updated, and a foundation is provided for establishing normal communication between the browser end and the local server end through the updated communication port.
In an optional manner of the embodiment of the present application, the method further includes:
and the browser end establishes communication with the local server end through the second http port.
In the embodiment of the application, the browser terminal can retry to establish communication with the local server terminal through the updated second http port.
Specifically, the browser side may poll each of the second http ports in turn.
In an optional manner of this embodiment, when establishing communication with the local server via the second http port, if the communication condition of the second http port satisfies the reconnection condition, the method further includes:
and taking the second http port as a first port, repeatedly executing the browser to send an update request for the first http port to the local server in a Websocket manner, so that the local server updates a port for establishing communication between the browser and the local server to the second http port based on the update request, and establishing communication between the browser and the local server through the second http port until a preset stop condition is met.
In the embodiment of the application, if it is determined that the communication condition of each second http port meets the preset reconnection condition, it may be considered that the communication between the browser side and the local server side cannot be established through the second http port, and the browser side may be used as the first port to repeatedly execute the operation of updating the communication port in the Websocket manner until the preset stopping condition is reached.
The communication between the browser end and the local service end is established through the updated communication port, and the success rate of establishing communication between the browser end and the local service end can be improved. In practical use, in order to avoid that a lot of time is occupied by updating the communication port for many times and establishing communication by using the updated communication port, and a long-time waiting for a user is caused, a stop condition can be preset to finish the process of establishing communication.
In an optional manner of the embodiment of the present application, the stop condition may include: the repeated execution times reach the preset times.
In the embodiment of the application, the maximum repeated execution times can be preset, when the repeated execution times reach the preset times, the repeated execution is not continued, and a prompt message for communication establishment failure is sent to a user.
In an optional manner of the embodiment of the application, the local server updates a port for establishing communication between the browser and the local server to the second http port based on the update request, and the method includes:
and the local server updates the port for establishing the communication between the browser terminal and the local server terminal into a second http port based on the port information of the second http port carried by the update request.
In the embodiment of the application, the browser end can determine the port information of the second http port and send the update request based on the port information of the second http port, and the local server end can update the port for establishing communication between the browser end and the local server end to the second http port.
In an optional manner of the embodiment of the present application, the sending, by the browser side, an update request for the first http port to the local server side in a Websocket manner includes:
determining whether a current operating system supports Websocket;
if the request is supported, the browser end sends an update request for the first http port to the local server end in a Websocket mode
In the embodiment of the application, before the communication port is updated, whether the current operating system of the device supports the Websocket communication mode or not can be determined, and if so, the communication port can be updated; if not, the process of establishing communication can be stopped.
Fig. 2 shows a flowchart of a specific implementation manner provided by an embodiment of the present application, and as shown in fig. 2, a browser end may set initial information such as a port (i.e., a first http port) and a maximum timeout T seconds (i.e., a preset duration) in advance through a local http mode.
The browser end can poll each first http port in sequence to initiate a communication request, and meanwhile, the local server end can monitor the communication request and return a communication establishment result to the browser end.
If the communication request is failed to be established or the communication request is over time for T seconds (that is, a preset reconnection condition is met), the N ports (that is, the second http port) may be updated to perform the next round of communication, specifically, after it is determined that the browser supports the communication mode of the Websocket, the N port information (that is, the port information of the second http port) may be negotiated through the communication mode of the Websocket, and the local server may update the second http port. And then, the local server can wait for trying to establish communication through the second http port, if a reconnection condition is met, the operation step of updating the communication port can be retried until the retry time is greater than C times (namely greater than a preset time), at this time, the process can be ended, and a prompt message of communication establishment failure is sent to the user.
Fig. 3 is a schematic flowchart illustrating another method for updating a data port according to an embodiment of the present application, where as shown in fig. 3, the method mainly includes:
step S210: when a browser establishes communication with a local server through a first Websocket port, determining whether the communication condition of the first Websocket port meets a preset reconnection condition;
step S220: and if so, the browser end sends an update request for the first Websocket port to the local server end in an http mode, so that the local server end updates a port for establishing communication between the browser end and the local server end to a second Websocket port based on the update request.
In the embodiment of the application, the first Websocket port may be a communication interface pre-established between the browser end and the local server end in a local Websocket manner.
In the embodiment of the application, when the browser end establishes communication with the local server through the first Websocket port, the browser end can poll each first Websocket port in sequence, and if the communication condition of each first Websocket port is determined to meet the preset reconnection condition, the browser end cannot establish communication with the local server through the first Websocket port.
In practical use, the reconnection condition may include that all the first Websocket ports fail to establish communication, or that all the first Websocket ports fail to establish communication within a preset time period.
Selecting the number of the ports of the first Websocket port and the preset duration, wherein user experience needs to be considered, suggesting that the number of the ports of the first Websocket port is 5-10, and the preset duration is less than 2 seconds.
In the embodiment of the application, when the communication condition of each first Websocket port meets the preset reconnection condition, the communication ports can be allocated again in an http communication manner, specifically, the browser end can send an update request for the first Websocket port to the local server end in the http communication manner, and the local server end updates the port for establishing communication between the browser end and the local server end to the second Websocket port based on the update request.
According to the method provided by the embodiment of the application, when the browser end establishes communication with the local server end through the first Websocket port, if the communication condition of the first Websocket port meets the preset reconnection condition, the browser end sends the update request for the first Websocket port to the local server end in a Websocket mode, so that the local server end updates the port for establishing communication between the browser end and the local server end into the second Websocket port based on the update request. Based on the scheme, when the communication between the browser end and the local server end cannot be established through the first Websocket port, the communication ports are distributed again in the http communication mode, the first Websocket port is updated, and a foundation is provided for establishing normal communication between the browser end and the local server end through the updated communication ports.
In an optional manner of the embodiment of the present application, the method further includes:
and the browser end establishes communication with the local server end through the second Websocket port.
In the embodiment of the application, the browser terminal can try to establish communication with the local server again through the updated second Websocket port.
Specifically, the browser side may poll each second Websocket port in turn.
In an optional manner of the embodiment of the application, when the browser establishes communication with the local server through the second Websocket port, if the communication condition of the second Websocket port satisfies the reconnection condition, the method further includes:
and taking the second Websocket port as the first Websocket port, repeatedly executing the browser to send an updating request for the first Websocket port to the local server in an http mode, so that the local server updates the port for establishing communication between the browser and the local server to the second Websocket port based on the updating request, and establishing communication between the browser and the local server through the second Websocket port until a preset stopping condition is met.
In the embodiment of the application, if it is determined that the communication condition of each second Websocket port meets the preset reconnection condition, it is considered that the communication between the browser side and the local server side cannot be established through the second Websocket port, and the communication port can be repeatedly updated in the http mode as the first port until the preset stopping condition is met.
The communication between the browser end and the local service end is established through the updated communication port, and the success rate of establishing communication between the browser end and the local service end can be improved. In practical use, in order to avoid that a lot of time is occupied by updating the communication port for many times and establishing communication by using the updated communication port, and a long-time waiting for a user is caused, a stop condition can be preset to finish the process of establishing communication.
In an optional manner of the embodiment of the present application, the stop condition may include: the repeated execution times reach the preset times.
In the embodiment of the application, the maximum repeated execution times can be preset, when the repeated execution times reach the preset times, the repeated execution is not continued, and a prompt message for communication establishment failure is sent to a user.
In an optional mode of the embodiment of the application, the local server updates a port for establishing communication between the browser and the local server to be a second Websocket port based on the update request, and the method includes the following steps:
and the local server updates the port for establishing the communication between the browser end and the local server end into a second Websocket port based on the port information of the second Websocket port carried by the update request.
In the embodiment of the application, the browser end can determine the port information of the second Websocket port, an updating request is sent based on the port information of the second Websocket port, and the local server end can update the port used for establishing communication between the browser end and the local server end to be the second Websocket port.
In an optional manner of the embodiment of the present application, the sending, by the browser side, an update request for the first Websocket port to the local server side in an http manner includes:
determining whether the browser side supports http;
and if the first Websocket port is supported, the browser side sends an update request for the first Websocket port to the local server side in an http mode.
In the embodiment of the application, before the communication port is updated, whether the current operating system of the device supports the http communication mode can be determined, and if so, the communication port can be updated; if not, the process of establishing communication can be stopped.
Based on the same principle as the method shown in fig. 1, fig. 4 shows a schematic structural diagram of an updating apparatus of a data port provided in an embodiment of the present application, and as shown in fig. 4, the updating apparatus 30 of the data port may include:
the communication condition monitoring module 310 is configured to determine whether a communication condition of the first http port meets a preset reconnection condition when the browser establishes communication with the local server through the first http port;
the port updating module 320 is configured to, when the communication condition of the first http port meets a preset reconnection condition, send, by the browser, an update request for the first http port to the local server in a Websocket manner, so that the local server updates, based on the update request, the port for establishing communication between the browser and the local server to the second http port.
According to the device provided by the embodiment of the application, when the browser end establishes communication with the local server end through the first http port, if the communication condition of the first http port meets the preset reconnection condition, the browser end sends the update request for the first http port to the local server end through a Websocket mode, so that the local server end updates the port for establishing communication between the browser end and the local server end to the second http port based on the update request. Based on the scheme, when the communication between the browser end and the local server end cannot be established through the first http port, the communication port is distributed again in a Websocket communication mode, the first http port is updated, and a foundation is provided for establishing normal communication between the browser end and the local server end through the updated communication port.
Optionally, the apparatus further comprises:
and the communication establishing module is used for establishing communication between the browser end and the local server end through the second http port.
Optionally, the communication establishing module is further configured to:
when the communication between the browser end and the local server end is established through the second http port, if the communication condition of the second http port meets a reconnection condition, the second http port is used as the first http port, the browser end is repeatedly executed to send an update request for the first http port to the local server end in a Websocket mode, so that the local server end updates a port for establishing the communication between the browser end and the local server end to the second http port based on the update request, and the browser end establishes the communication with the local server end through the second http port until a preset stop condition is met.
Optionally, the reconnect condition comprises at least one of:
all the ports in the first http port or the second http port fail to establish communication;
all the ports in the first http port or the second http port cannot establish communication within a preset time.
Optionally, the stop condition comprises:
the repeated execution times reach the preset times.
Optionally, the local server updates the port for establishing communication between the browser side and the local server side to the second http port based on the update request, by:
and the local server updates the port for establishing the communication between the browser terminal and the local server terminal into the second http port based on the port information of the second http port carried by the update request.
Optionally, when the browser sends an update request for the first http port to the local server in a Websocket manner, the port update module is specifically configured to:
determining whether the browser end supports Websocket;
and if the request is supported, the browser end sends an update request for the first http port to the local server end in a Websocket mode.
It can be understood that the above modules of the data port updating apparatus in this embodiment have functions of implementing corresponding steps of the data port updating method in the embodiment shown in fig. 1. The function can be realized by hardware, and can also be realized by executing corresponding software by hardware. The hardware or software includes one or more modules corresponding to the functions described above. The modules can be software and/or hardware, and each module can be implemented independently or by integrating a plurality of modules. For the functional description of each module of the data port updating apparatus, reference may be specifically made to the corresponding description of the data port updating method in the embodiment shown in fig. 1, and details are not repeated here.
Based on the same principle as the method shown in fig. 3, fig. 5 shows a schematic structural diagram of an updating apparatus of a data port provided in an embodiment of the present application, and as shown in fig. 5, the updating apparatus 40 of the data port may include:
the communication condition monitoring module 410 is used for determining whether the communication condition of the first Websocket port meets a preset reconnection condition when the browser end establishes communication with the local server through the first Websocket port;
and the port updating module 420 is configured to, when the communication condition of the first Websocket port meets a preset reconnection condition, send, by the browser, an update request for the first Websocket port to the local server in an http manner, so that the local server updates, based on the update request, a port for establishing communication between the browser and the local server to the second Websocket port.
According to the device provided by the embodiment of the application, when the browser end establishes communication with the local server end through the first Websocket port, if the communication condition of the first Websocket port meets the preset reconnection condition, the browser end sends the update request for the first Websocket port to the local server end in a Websocket mode, so that the local server end updates the port for establishing communication between the browser end and the local server end into the second Websocket port based on the update request. Based on the scheme, when the communication between the browser end and the local server end cannot be established through the first Websocket port, the communication port can be distributed again in the http communication mode, the first Websocket port is updated, and a foundation is provided for establishing normal communication between the browser end and the local server end through the updated communication port.
Optionally, the apparatus further comprises:
and the communication establishing module is used for establishing communication between the browser end and the local server end through the second Websocket port.
Optionally, the communication establishing module is further configured to:
when the browser establishes communication with the local server through the second Websocket port, if the communication condition of the second Websocket port meets the reconnection condition, the second Websocket port is used as the first Websocket port, the browser is repeatedly executed to send an updating request for the first Websocket port to the local server in an http mode, so that the local server updates the port used for establishing communication between the browser and the local server to the second Websocket port based on the updating request, and the browser establishes communication with the local server through the second Websocket port until the preset stopping condition is met.
Optionally, the reconnect condition comprises at least one of:
all ports in the first Websocket port or the second Websocket port fail to establish communication;
all the ports in the first Websocket port or the second Websocket port cannot establish communication within a preset time length.
Optionally, the stop condition comprises:
the repeated execution times reach the preset times.
Optionally, the local server updates a port for establishing communication between the browser and the local server to the second Websocket port based on the update request, and by the following means:
and the local server updates the port for establishing the communication between the browser and the local server to be the second Websocket port based on the port information of the second Websocket port carried by the update request.
Optionally, when the browser sends an update request for the first Websocket port to the local server in an http manner, the port update module is specifically configured to:
determining whether the browser side supports http;
and if the first Websocket port is supported, the browser side sends an update request for the first Websocket port to the local server side in an http mode.
It can be understood that the above modules of the data port updating apparatus in this embodiment have functions of implementing corresponding steps of the data port updating method in the embodiment shown in fig. 3. The function can be realized by hardware, and can also be realized by executing corresponding software by hardware. The hardware or software includes one or more modules corresponding to the functions described above. The modules may be software and/or hardware, and each module may be implemented separately or implemented by integrating a plurality of modules. For the functional description of each module of the data port updating apparatus, reference may be specifically made to the corresponding description of the data port updating method in the embodiment shown in fig. 3, and details are not repeated here.
The embodiment of the application provides an electronic device, which comprises a processor and a memory;
a memory for storing operating instructions;
and the processor is used for executing the data port updating method provided by any embodiment of the application by calling the operation instruction.
As an example, fig. 6 shows a schematic structural diagram of an electronic device to which the embodiment of the present application is applied, and as shown in fig. 6, the electronic device 2000 includes: a processor 2001 and a memory 2003. Wherein the processor 2001 is coupled to a memory 2003, such as via a bus 2002. Optionally, the electronic device 2000 may also include a transceiver 2004. It should be noted that the transceiver 2004 is not limited to one in practical applications, and the structure of the electronic device 2000 is not limited to the embodiment of the present application.
The processor 2001 is applied to the embodiment of the present application to implement the method shown in the above method embodiment. The transceiver 2004 may include a receiver and a transmitter, and the transceiver 2004 is applied to the embodiments of the present application to implement the function of the electronic device of the embodiments of the present application to communicate with other devices when executed.
Processor 2001 may be a CPU (Central Processing Unit), general purpose Processor, DSP (Digital Signal Processor), ASIC (Application Specific Integrated Circuit), FPGA (Field Programmable Gate Array), or other Programmable logic device, transistor logic, hardware component, or any combination thereof. Which may implement or perform the various illustrative logical blocks, modules, and circuits described in connection with the disclosure. The processor 2001 may also be a combination of computing functions, e.g., comprising one or more microprocessors, DSPs and microprocessors, and the like.
Bus 2002 may include a path that conveys information between the aforementioned components. The bus 2002 may be a PCI (Peripheral Component Interconnect) bus, an EISA (Extended Industry Standard Architecture) bus, or the like. The bus 2002 may be divided into an address bus, a data bus, a control bus, and so on. For ease of illustration, only one thick line is shown in FIG. 6, but this is not intended to represent only one bus or type of bus.
The Memory 2003 may be a ROM (Read Only Memory) or other type of static storage device that can store static information and instructions, a RAM (Random Access Memory) or other type of dynamic storage device that can store information and instructions, an EEPROM (Electrically Erasable Programmable Read Only Memory), a CD-ROM (Compact Disc Read Only Memory) or other optical Disc storage, optical Disc storage (including Compact Disc, laser Disc, optical Disc, digital versatile Disc, blu-ray Disc, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a computer, but is not limited to these.
Optionally, the memory 2003 is used for storing application program code for performing the disclosed aspects, and is controlled in execution by the processor 2001. The processor 2001 is configured to execute the application program code stored in the memory 2003 to implement the method for updating the data port provided in any of the embodiments of the present application.
The electronic device provided by the embodiment of the application is applicable to any embodiment of the method, and is not described herein again.
Compared with the prior art, when the browser end establishes communication with the local server end through the first http port, if the communication condition of the first http port meets a preset reconnection condition, the browser end sends an update request for the first http port to the local server end in a Websocket mode, so that the local server end updates a port for establishing communication between the browser end and the local server end to the second http port based on the update request. Based on the scheme, when the communication between the browser end and the local server end cannot be established through the first http port, the communication port can be distributed again in a Websocket communication mode, the first http port is updated, and a foundation is provided for establishing normal communication between the browser end and the local server end through the updated communication port.
The embodiment of the present application provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the computer program implements the method for updating a data port shown in the above method embodiment.
The computer-readable storage medium provided in the embodiments of the present application is applicable to any of the embodiments of the foregoing method, and is not described herein again.
Compared with the prior art, when the browser end establishes communication with the local server end through the first http port, if the communication condition of the first http port meets a preset reconnection condition, the browser end sends an update request for the first http port to the local server end in a Websocket manner, so that the local server end updates a port for establishing communication between the browser end and the local server end to the second http port based on the update request. Based on the scheme, when the communication between the browser end and the local server end cannot be established through the first http port, the communication port is distributed again in a Websocket communication mode, the first http port is updated, and a foundation is provided for establishing normal communication between the browser end and the local server end through the updated communication port.
It should be understood that, although the steps in the flowcharts of the figures are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and may be performed in other orders unless explicitly stated herein. Moreover, at least a portion of the steps in the flow chart of the figure may include multiple sub-steps or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, which are not necessarily performed in sequence, but may be performed alternately or alternately with other steps or at least a portion of the sub-steps or stages of other steps.
The foregoing is only a partial embodiment of the present invention, and it should be noted that, for those skilled in the art, various modifications and embellishments can be made without departing from the principle of the present invention, and these should also be construed as the scope of the present invention.

Claims (13)

1. A method for updating a data port, comprising:
when a browser establishes communication with a local server through a first http port, determining whether the communication condition of the first http port meets a preset reconnection condition;
if the first http port is satisfied, the browser sends an update request for the first http port to the local server in a Websocket manner, so that the local server updates a port for establishing communication between the browser and the local server to a second http port based on the update request.
2. The method of claim 1, further comprising:
and the browser end establishes communication with the local server end through the second http port.
3. The method of claim 2, wherein when the communication with the local service end is established through the second http port, if the communication condition of the second http port satisfies the reconnection condition, the method further comprises:
and taking the second http port as the first http port, repeatedly executing the browser to send an update request to the first http port to the local server in a Websocket manner, so that the local server updates a port for establishing communication between the browser and the local server to the second http port based on the update request, and establishing communication between the browser and the local server through the second http port until a preset stop condition is met.
4. The method of claim 3, wherein the communication condition of the first http port meeting the predetermined reconnection condition comprises at least one of:
all the ports in the first http port fail to establish communication;
all the ports in the first http port cannot establish communication within a preset time length;
the communication condition of the second http port meeting the reconnection condition includes at least one of:
all the ports in the second http port fail to establish communication;
and all the ports in the second http port cannot establish communication within a preset time length.
5. The method of claim 3, wherein the stop condition comprises:
the repeated execution times reach the preset times.
6. The method according to any one of claims 1 to 5, wherein the local server updates the port for establishing communication between the browser side and the local server side to the second http port based on the update request by:
and the local server updates a port for establishing communication between the browser terminal and the local server terminal to be a second http port based on the port information of the second http port carried by the update request.
7. The method according to any one of claims 1-5, wherein the sending, by the browser side, an update request for the first http port to the local server side through a Websocket manner includes:
determining whether the browser end supports Websocket;
and if so, the browser end sends an update request for the first http port to the local server end in a Websocket mode.
8. A method for updating a data port, comprising:
when a browser establishes communication with a local server through a first Websocket port, determining whether the communication condition of the first Websocket port meets a preset reconnection condition;
if the first Websocket port is met, the browser end sends an update request for the first Websocket port to the local server end in an http mode, so that the local server end updates a port for establishing communication between the browser end and the local server end to a second Websocket port based on the update request.
9. The method of claim 8, wherein when the browser side establishes communication with the local server side through the second Websocket port, if a communication condition of the second Websocket port meets the reconnection condition, the method further comprises:
and taking the second Websocket port as the first Websocket port, repeatedly executing the update request sent to the first Websocket port by the browser end to the local server end in an http mode, so that the local server end updates the port used for establishing the communication between the browser end and the local server end to the second Websocket port based on the update request, and establishing the communication between the browser end and the local server end through the second Websocket port until a preset stop condition is met.
10. An update apparatus for a data port, comprising:
the communication condition monitoring module is used for determining whether the communication condition of the first http port meets a preset reconnection condition when the browser establishes communication with a local server through the first http port;
and the port updating module is used for sending an updating request for the first http port to the local server in a Websocket mode when the communication condition of the first http port meets a preset reconnection condition, so that the local server updates a port for establishing communication between the browser and the local server to a second http port based on the updating request.
11. An update apparatus for a data port, comprising:
the communication condition monitoring module is used for determining whether the communication condition of a first Websocket port meets a preset reconnection condition or not when a browser establishes communication with a local server through the first Websocket port;
and the port updating module is used for sending an updating request for the first Websocket port to the local server in an http mode when the communication condition of the first Websocket port meets a preset reconnection condition, so that the local server updates a port for establishing communication between the browser and the local server to a second Websocket port based on the updating request.
12. An electronic device comprising a processor and a memory;
the memory is used for storing operation instructions;
the processor is used for executing the method of any one of claims 1-9 by calling the operation instruction.
13. A computer-readable storage medium, characterized in that the storage medium has stored thereon a computer program which, when being executed by a processor, carries out the method of any one of claims 1-9.
CN202011285062.3A 2020-11-17 2020-11-17 Data port updating method and device, electronic equipment and readable storage medium Active CN112637121B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011285062.3A CN112637121B (en) 2020-11-17 2020-11-17 Data port updating method and device, electronic equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011285062.3A CN112637121B (en) 2020-11-17 2020-11-17 Data port updating method and device, electronic equipment and readable storage medium

Publications (2)

Publication Number Publication Date
CN112637121A CN112637121A (en) 2021-04-09
CN112637121B true CN112637121B (en) 2022-10-25

Family

ID=75304383

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011285062.3A Active CN112637121B (en) 2020-11-17 2020-11-17 Data port updating method and device, electronic equipment and readable storage medium

Country Status (1)

Country Link
CN (1) CN112637121B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114268657B (en) * 2021-12-24 2024-05-24 北京天威诚信电子商务服务有限公司 Method and system for establishing SSL_TLS communication between browser application and local application

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8135616B2 (en) * 2008-06-26 2012-03-13 Microsoft Corporation Browsing and quality of service features
CN104410550B (en) * 2014-12-10 2018-05-01 深圳中兴网信科技有限公司 Web service monitoring method and web service monitoring device
US10782981B2 (en) * 2018-01-26 2020-09-22 Avaya Inc. Systems and methods of dynamic port assignment
CN110309476B (en) * 2019-07-05 2021-05-25 上海中通吉网络技术有限公司 Method and device for calling local application program by webpage browser

Also Published As

Publication number Publication date
CN112637121A (en) 2021-04-09

Similar Documents

Publication Publication Date Title
CN108712485B (en) Resource subscription method and device for Internet of things equipment
CN111278031A (en) PDU type setting method, UE strategy setting method and related entity
CN110808948B (en) Remote procedure calling method, device and system
CN108055311B (en) HTTP asynchronous request method, device, server, terminal and storage medium
CN108833205B (en) Information processing method, information processing device, electronic equipment and storage medium
CN112637121B (en) Data port updating method and device, electronic equipment and readable storage medium
CN112948098B (en) Service unit offline method based on micro-service unit architecture and related device
CN112818336A (en) Data access method, data access device and computer readable storage medium
CN112511603B (en) Data port updating method and device, electronic equipment and readable storage medium
CN112532699B (en) Data port updating method and device, electronic equipment and readable storage medium
CN111913815A (en) Call request processing method and device, electronic equipment and readable storage medium
WO2019201111A1 (en) Information processing method, apparatus and device, and computer-readable storage medium
CN108282752B (en) Method, system, device and storage medium for group callback in broadband cluster system
CN114697339A (en) Load balancing method and device under centralized architecture
CN112770277B (en) Forwarding number verification method and device, mobile terminal and computing equipment
CN113434234A (en) Page jump method, device, computer readable storage medium and processor
CN114363204A (en) Request monitoring method, network device and storage medium
CN113867145A (en) Application control method and device, electronic equipment and storage medium
CN111782366A (en) Distributed task scheduling method and device
CN112769824B (en) Information transmission state updating method, terminal, device and storage medium
CN110716972A (en) Method and device for processing error of high-frequency calling external interface
CN117201577B (en) Communication method and system of cross-platform API and SPI based on PISA
CN116743728B (en) Application operation and maintenance method, system, equipment and storage medium
CN113472841B (en) Implementation method and device for terminating remote procedure call request
CN115622988B (en) Call response method and device for web interface, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant