connect = async logger => {
  if (config.get('localTunnel.enabled') !== true) {
    logger.info('Local tunnel is disabled');
    await cache.hdel('trailing-trade-common', 'local-tunnel-url');
    return false;
  }

  logger.info('Attempt connecting local tunnel');
  let tunnel;
  try {
    tunnel = await localtunnel({
      port: config.get('frontend.port'),
      subdomain: config.get('localTunnel.subdomain')
    });
    logger.info({ url: tunnel.url }, 'Connected local tunnel');
    isReconnecting = false;
  } catch (e) {
    reconnect(
      logger,
      `Local tunnel got an exception, try to connect after ${
        retryMs / 1000
      } secs.`,
      10000
    );
    return null;
  }

  // Get config for local tunnel url
  const cachedLocalTunnelURL = await cache.hget(
    'trailing-trade-common',
    'local-tunnel-url'
  );

  // If new url is different, then notify slack
  if (cachedLocalTunnelURL !== tunnel.url) {
    // Save config with local tunnel url
    await cache.hset('trailing-trade-common', 'local-tunnel-url', tunnel.url);

    slack.sendMessage(`*Public URL:* ${tunnel.url}`, { symbol: 'global' });
    logger.info(
      { localTunnelURL: tunnel.url },
      'New URL detected, sent to Slack.'
    );
  }

  if (tunnel.url.includes(config.get('localTunnel.subdomain')) === true) {
    // If new url is configured subdomain, then reset retry.
    retryMs = 60 * 60 * 1000;
  } else {
    // If new url is not configured subdomain, then retry to connect later
    reconnect(
      logger,
      `Local tunnel is different with configured subdomain. Try after ${
        retryMs / 1000
      } secs.`,
      retryMs
    );
  }

  tunnel.on('error', () => {
    // tunnels are closed
    reconnect(
      logger,
      `Local tunnel got an error, try to connect after ${retryMs / 1000} secs.`,
      retryMs
    );
  });

  tunnel.on('close', () => {
    reconnect(
      logger,
      `Local tunnel closed, try to connect after ${retryMs / 1000} secs.`,
      retryMs
    );
  });

  return tunnel;
}
Connect to the local tunnel

@param {*} logger
@returns