Home > Article > Backend Development > Does Ngrok Use Polling to Detect Incoming Data Behind Restrictive Firewalls?
Ngrok's Solution to Firewall Obstacles
Ngrok's primary function is to facilitate the exposure of local ports and services to the internet via forwarding. However, when using ngrok behind a restrictive firewall that blocks incoming traffic, concerns arise about whether ngrok employs polling mechanisms to detect incoming data.
Ngrok's Client-Initiated Tunnel
In contrast to traditional approaches, ngrok establishes tunnels from the client side first. This strategy enables ngrok to establish a secure connection with the server, even behind firewalls.
Stream Multiplexing: A Novel Technique
Ngrok deploys an innovative technique known as stream multiplexing within a long-lived TCP connection. This approach allows the creation of multiple logical sockets within a single physical connection.
Unnecessary Polling
The implementation of stream multiplexing eliminates the need for polling. The client and server maintain bidirectional communication through the long-lived TCP connection, eliminating the requirement for periodic requests to check for data.
Heartbeat Mechanism for Reliability
To ensure the stability of the connection, ngrok employs a heartbeat mechanism. This mechanism continuously monitors the connection, and in case of errors or connection loss, it initiates a reconnection process.
Additional Resources
For further insights, refer to the Developer Guide hosted on GitHub: [link to Developer Guide]
The above is the detailed content of Does Ngrok Use Polling to Detect Incoming Data Behind Restrictive Firewalls?. For more information, please follow other related articles on the PHP Chinese website!