Class NgrokProcess


  • public class NgrokProcess
    extends java.lang.Object
    An object containing information about the ngrok process. Can be configured with JavaNgrokConfig.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getApiUrl()
      Get the API URL for the ngrok web interface.
      NgrokInstaller getNgrokInstaller()
      Get the class used to download and install ngrok.
      NgrokProcess.ProcessMonitor getProcessMonitor()
      Get the Runnable that is monitoring the ngrok thread.
      java.lang.String getVersion()
      Get the ngrok version.
      boolean isRunning()
      Check if this object is currently managing a running ngrok process.
      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.).
      void start()
      If not already running, start a ngrok process with no tunnels.
      void stop()
      Terminate the ngrok processes, if running.
      void update()
      Update ngrok, if an update is available.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • start

        public void start()
        If not already running, start a ngrok process with no tunnels. This will start the ngrok web interface, against which HTTP requests can be made to create, interact with, and destroy tunnels.
      • isRunning

        public boolean isRunning()
        Check if this object is currently managing a running ngrok process.
      • stop

        public void stop()
        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.).
         // Setting an auth token allows us to do things like open multiple tunnels at the same time
         final NgrokClient ngrokClient = new NgrokClient.Builder().build();
         ngrokClient.setAuthToken("")
        
         // <NgrokTunnel: "http://<public_sub1>.ngrok.io" -> "http://localhost:80">
         final Tunnel ngrokTunnel1 = ngrokClient.connect();
         // <NgrokTunnel: "http://<public_sub2>.ngrok.io" -> "http://localhost:8000">
         final CreateTunnel sshCreateTunnel = new CreateTunnel.Builder()
                 .withAddr(8000)
                 .build();
         final Tunnel ngrokTunnel2 = ngrokClient.connect(createTunnel);
         

        The auth token can also be set in the JavaNgrokConfig that is passed to the NgrokClient.Builder.

        Parameters:
        authToken - The auth token.
      • update

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

        public java.lang.String getVersion()
        Get the ngrok version.
        Returns:
        The version.
      • getApiUrl

        public java.lang.String getApiUrl()
        Get the API URL for the ngrok web interface.
      • getNgrokInstaller

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