mitipi / serverless-ngrok-tunnel

Serverless plugin that creates ngrok public tunnel on localhost.
MIT License
9 stars 9 forks source link

Tunnel not starting #1

Open alex88 opened 5 years ago

alex88 commented 5 years ago

I'm trying to use this plugin, I've added it to my config:

custom:
  stage: "${opt:stage, self:provider.stage, 'dev'}"
  production:
    GW_URL: { "Fn::Join" : ["", [ "https://", { "Ref" : "ApiGatewayRestApi" }, ".execute-api.${self:custom.region, ''}.amazonaws.com/${self:custom.stage}" ] ]  }
  dev:
    GW_URL: "http://localhost:3000"
  ngrokTunnel:
    envPath: .env
    tunnels:
      - port: 3000
        envProp: 'API_GATEWAY'

plugins:
  - serverless-ngrok-tunnel
  - serverless-offline

however when I do sls tunnel it just shows Serverless: Starting tunnels... and then it quits.

I've tried to log some values around here:

  runTunnel ({port, envProp, ws, path, ngrokOptions}) {
    try {
      ngrok.connect({
        addr: port,
        proto: 'http',
        region: 'eu',
        ...(ngrokOptions || {})
      }, (err, url) => {
        console.log('callback');
        if (err) {
          this.log(`Unable to create tunnel: ${err.message}`)
        } else {
          this.onConnect(url, envProp, ws, path)
        }
      })

      ngrok.on('disconnect', () => this.onTunnelClose())
      ngrok.on('error', (e) => this.errorHandler(e))
    } catch (e) {
      this.errorHandler(e)
    }
  }

and it calls ngrock.connect but nothing else, the callback nor the catch or the disconnect/error event handlers are called

Node 12.4.0 on OSX 10.14.5

nenadpnc commented 5 years ago

Put serverless-ngrok-tunnel after serverless-offline in serverless.yml, it should work.