Class JavaNgrokConfig


  • public class JavaNgrokConfig
    extends java.lang.Object
    An object for managing java-ngrok's configuration to interact the ngrok binary.

    Basic Usage

     final Function<NgrokLog, Void> logEventCallback = ngrokLog -> {
         System.out.println(ngrokLog.getLine());
         return null;
     };
     final JavaNgrokConfig javaNgrokConfig = new JavaNgrokConfig.Builder()
             .withAuthToken("<NGROK_AUTHTOKEN>")
             .withApiKey("<NGROK_API_KEY>")
             .withRegion(Region.AU)
             .withLogEventCallback(logEventCallback)
             .withMaxLogs(10);
    
     final NgrokClient ngrokClient = new NgrokClient.Builder()
             .withJavaNgrokConfig(javaNgrokConfig)
             .build();
     

    ngrok Version Compatibility

    java-ngrok is compatible with ngrok v2 and v3, but by default it will install v3. To install v2 instead, set the version with JavaNgrokConfig.Builder.withNgrokVersion(NgrokVersion) and CreateTunnel.Builder.withNgrokVersion(NgrokVersion).
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getApiKey()
      A ngrok API key.
      java.lang.String getAuthToken()
      Get the ngrok authtoken that will be passed to commands.
      java.nio.file.Path getConfigPath()
      Get the path to the ngrok config file.
      ConfigVersion getConfigVersion()
      The ngrok config version.
      java.util.function.Function<NgrokLog,​java.lang.Void> getLogEventCallback()
      Get the log event callback that will be invoked each time ngrok emits a log.
      int getMaxLogs()
      Get the maximum number of ngrok logs to retain in the monitoring thread.
      java.nio.file.Path getNgrokPath()
      Get the path to the ngrok binary.
      NgrokVersion getNgrokVersion()
      Get the major ngrok version to be used.
      Region getRegion()
      Get the region in which ngrok will start.
      int getStartupTimeout()
      Get the max timeout, in seconds, to wait for ngrok to start.
      boolean isKeepMonitoring()
      Get whether the ngrok process will continue to be monitored after it finishes starting up.
      • Methods inherited from class java.lang.Object

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

      • getNgrokVersion

        public NgrokVersion getNgrokVersion()
        Get the major ngrok version to be used.
      • getMaxLogs

        public int getMaxLogs()
        Get the maximum number of ngrok logs to retain in the monitoring thread.
      • getStartupTimeout

        public int getStartupTimeout()
        Get the max timeout, in seconds, to wait for ngrok to start.
      • isKeepMonitoring

        public boolean isKeepMonitoring()
        Get whether the ngrok process will continue to be monitored after it finishes starting up.
      • getNgrokPath

        public java.nio.file.Path getNgrokPath()
        Get the path to the ngrok binary.
      • getConfigPath

        public java.nio.file.Path getConfigPath()
        Get the path to the ngrok config file.
      • getAuthToken

        public java.lang.String getAuthToken()
        Get the ngrok authtoken that will be passed to commands.
      • getRegion

        public Region getRegion()
        Get the region in which ngrok will start.
      • getLogEventCallback

        public java.util.function.Function<NgrokLog,​java.lang.Void> getLogEventCallback()
        Get the log event callback that will be invoked each time ngrok emits a log.
      • getApiKey

        public java.lang.String getApiKey()
        A ngrok API key.
      • getConfigVersion

        public ConfigVersion getConfigVersion()
        The ngrok config version.