Class NgrokClient


  • public class NgrokClient
    extends java.lang.Object
    A client for interacting with ngrok, its binary, and its APIs. Can be configured with JavaNgrokConfig.
    • Method Detail

      • connect

        public Tunnel connect​(CreateTunnel createTunnel)
        Establish a new ngrok tunnel for the tunnel definition, returning an object representing the connected tunnel.

        ngrok's default behavior for http when no additional properties are passed is to open two tunnels, one http and one https. This method will return a reference to the http tunnel in this case. If only a single tunnel is needed, call CreateTunnel.Builder.withBindTls(boolean) with true and a reference to the https tunnel will be returned.

        Parameters:
        createTunnel - The tunnel definition.
        Returns:
        The created Tunnel.
      • disconnect

        public void disconnect​(java.lang.String publicUrl)
        Disconnect the ngrok tunnel for the given URL, if open.
        Parameters:
        publicUrl - The public URL of the tunnel to disconnect.
      • getTunnels

        public Tunnels getTunnels()
        Get a list of active ngrok tunnels.
        Returns:
        The active ngrok tunnels.
      • kill

        public void kill()
        Terminate the ngrok processes, if running. This method will not block, it will just issue a kill request.
      • setAuthToken

        public void setAuthToken​(java.lang.String authToken)
        Set the ngrok auth token in the config file, enabling authenticated features (for instance, more concurrent tunnels, custom subdomains, etc.).
        Parameters:
        authToken - The auth token.
      • update

        public void update()
        Update ngrok, if an update is available.
      • getVersion

        public Version getVersion()
        Get the ngrok and java-ngrok version.
        Returns:
        The versions.
      • getJavaNgrokConfig

        public JavaNgrokConfig getJavaNgrokConfig()
        Get the java-ngrok to use when interacting with the ngrok binary.
      • getNgrokInstaller

        public NgrokInstaller getNgrokInstaller()
        Get the class used to download and install ngrok.
      • getNgrokProcess

        public NgrokProcess getNgrokProcess()
        Get the class used to manage the ngrok binary.
      • getHttpClient

        public HttpClient getHttpClient()
        Get the class used to make HTTP requests to ngrok's APIs.