twilio / twilio-cli

Unleash the power of Twilio from your command prompt
MIT License
161 stars 79 forks source link

Twilio-CLI Unexpected Error #555

Closed Aayuss closed 8 months ago

Aayuss commented 11 months ago

Issue Summary

While following through the docs provided by Twilio, after installing Twilio using homebrew, I paste the code mentioned below. And I'm getting the error mentioned below.

Steps to Reproduce

  1. Go to Terminal
  2. Paste twilio phone-numbers:update "+18442615019" --sms-url="http://localhost:1337/sms"

Code Snippet

twilio phone-numbers:update "+18442615019" --sms-url="http://localhost:1337/sms" -l debug

Exception/Log

[DEBUG] Config File: /Users/aayuss/.twilio-cli/config.json
[DEBUG] Using profile: AP
[DEBUG] -- BEGIN Twilio API Request --
[DEBUG] get https://api.twilio.com/2010-04-01/Accounts/AC113023f9d46ed54c4b04df74633732d3/IncomingPhoneNumbers.json
[DEBUG] Querystring:
[DEBUG] {"PhoneNumber":"+18442615019"}
[DEBUG] Custom HTTP Headers:
[DEBUG] User-Agent: twilio-cli/5.15.0 @twilio/cli-core/7.17.0 (darwin arm64) twilio-node/4.18.0 node/v18.16.1 phone-numbers:update
[DEBUG] -- END Twilio API Request --
[DEBUG] response.statusCode: 200
[DEBUG] response.headers: {"date":"Tue, 03 Oct 2023 10:44:03 GMT","content-type":"application/json; charset=utf-8","content-length":"1855","connection":"close","twilio-request-id":"RQde7b8496ce672052b2285697bca574a7","twilio-request-duration":"0.138","access-control-allow-origin":"*","access-control-allow-headers":"Accept, Authorization, Content-Type, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since, Idempotency-Key","access-control-allow-methods":"GET, POST, DELETE, OPTIONS","access-control-expose-headers":"ETag","access-control-allow-credentials":"true","x-powered-by":"AT-5000","strict-transport-security":"max-age=31536000","twilio-concurrent-requests":"1","x-shenanigans":"none","x-home-region":"us1","x-api-domain":"api.twilio.com"}
[DEBUG] ngrok: t=2023-10-03T16:29:03+0545 lvl=info msg="no configuration paths supplied"
t=2023-10-03T16:29:03+0545 lvl=info msg="ignoring default config path, could not stat it" path=/Users/aayuss/.ngrok2/ngrok.yml err="stat /Users/aayuss/.ngrok2/ngrok.yml: no such file or directory"
[DEBUG] ngrok: t=2023-10-03T16:29:03+0545 lvl=info msg="starting web service" obj=web addr=127.0.0.1:4040
[DEBUG] ngrok: t=2023-10-03T16:29:03+0545 lvl=info msg=start pg=/api/tunnels id=c12ba35b0d5331ca
[DEBUG] ngrok: t=2023-10-03T16:29:03+0545 lvl=warn msg="ngrok is not yet ready to start tunnels" pg=/api/tunnels id=c12ba35b0d5331ca err="a successful ngrok tunnel session has not yet been established"
[DEBUG] ngrok: t=2023-10-03T16:29:03+0545 lvl=info msg=end pg=/api/tunnels id=c12ba35b0d5331ca status=503 dur=6.505125ms
[DEBUG] ngrok: t=2023-10-03T16:29:03+0545 lvl=info msg=start pg=/api/tunnels id=8337c570859af65a
[DEBUG] ngrok: t=2023-10-03T16:29:03+0545 lvl=warn msg="ngrok is not yet ready to start tunnels" pg=/api/tunnels id=8337c570859af65a err="a successful ngrok tunnel session has not yet been established"
t=2023-10-03T16:29:03+0545 lvl=info msg=end pg=/api/tunnels id=8337c570859af65a status=503 dur=326.416µs
[DEBUG] ngrok: t=2023-10-03T16:29:03+0545 lvl=info msg=start pg=/api/tunnels id=0f0026d848d72f98
[DEBUG] ngrok: t=2023-10-03T16:29:03+0545 lvl=warn msg="ngrok is not yet ready to start tunnels" pg=/api/tunnels id=0f0026d848d72f98 err="a successful ngrok tunnel session has not yet been established"
[DEBUG] ngrok: t=2023-10-03T16:29:03+0545 lvl=info msg=end pg=/api/tunnels id=0f0026d848d72f98 status=503 dur=674.791µs
[DEBUG] ngrok: t=2023-10-03T16:29:04+0545 lvl=info msg=start pg=/api/tunnels id=d7240b9707ddca9c
[DEBUG] ngrok: t=2023-10-03T16:29:04+0545 lvl=warn msg="ngrok is not yet ready to start tunnels" pg=/api/tunnels id=d7240b9707ddca9c err="a successful ngrok tunnel session has not yet been established"
[DEBUG] ngrok: t=2023-10-03T16:29:04+0545 lvl=info msg=end pg=/api/tunnels id=d7240b9707ddca9c status=503 dur=650.542µs
[DEBUG] ngrok: t=2023-10-03T16:29:04+0545 lvl=info msg=start pg=/api/tunnels id=1868831e3183a025
[DEBUG] ngrok: t=2023-10-03T16:29:04+0545 lvl=info msg="tunnel session started" obj=tunnels.session
[DEBUG] ngrok: t=2023-10-03T16:29:04+0545 lvl=info msg="client session established" obj=csess id=2e68257b4b28
[DEBUG] ngrok: t=2023-10-03T16:29:04+0545 lvl=warn msg="failed to start tunnel" pg=/api/tunnels id=1868831e3183a025 err="An account is required to use host header rewrite.\n\nPlease register for an ngrok account at: https://dashboard.ngrok.com/signup and install your authtoken.\r\n\r\nERR_NGROK_9018\r\n"
[DEBUG] ngrok: t=2023-10-03T16:29:04+0545 lvl=info msg=end pg=/api/tunnels id=1868831e3183a025 status=502 dur=477.701292ms
[DEBUG] Found command "phone-numbers:update" plugin: twilio-cli
 » twilio-cli encountered an unexpected error. To report this issue, execute the command with the "-l debug" flag, then copy the output to a new issue here: "https://github.com/twilio/twilio-cli/issues"
[DEBUG] Converting circular structure to JSON
    --> starting at object with constructor 'Socket'
    |     property '_httpMessage' -> object with constructor 'ClientRequest'
    --- property 'socket' closes the circle
[DEBUG] TypeError: Converting circular structure to JSON
    --> starting at object with constructor 'Socket'
    |     property '_httpMessage' -> object with constructor 'ClientRequest'
    --- property 'socket' closes the circle
    at JSON.stringify (<anonymous>)
    at NumberUpdate.createTunnel (/opt/homebrew/Cellar/twilio/5.15.0/libexec/src/commands/phone-numbers/update.js:94:51)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async NumberUpdate.run (/opt/homebrew/Cellar/twilio/5.15.0/libexec/src/commands/phone-numbers/update.js:48:9)
    at async NumberUpdate._run (/opt/homebrew/Cellar/twilio/5.15.0/libexec/node_modules/@oclif/core/lib/command.js:80:22)
    at async Config.runCommand (/opt/homebrew/Cellar/twilio/5.15.0/libexec/node_modules/@oclif/core/lib/config/config.js:301:25)

Technical details:

tkcsam commented 10 months ago

I had the same problem and was able to resolve it with a little file manipulation magic. The problem is more with ngrok than Twilio.

  1. Sign up for an account at ngrok.com
  2. Follow the Setup & Installation instructions. In particular, setting your ngrok auth token via the terminal
  3. After issuing the ngrok config add-token command, the ngrok.yml config file location will be printed to the terminal
  4. In the stacktrace you provided above, there is one particular piece of important information: msg="ignoring default config path, could not stat it" path=/Users/aayuss/.ngrok2/ngrok.yml err="stat /Users/aayuss/.ngrok2/ngrok.yml: no such file or directory"
  5. Make a copy of the file generated in step 2 (printed in step 3) and paste it at /Users/aayuss/.ngrok2/ngrok.yml
jescalan commented 10 months ago

@tkcsam you are a legend, thank you, this did the trick for me as well. Given that the twilio quickstart guide for node.js is completely busted because of this, I feel like maybe it's worth running an update of some sort, if anyone on the twilio team is looking at this. I'm shocked that there's not more activity here given how long this has been broken for

jescalan commented 10 months ago

Ah wait, unfortunately it still appears to be broken - even once the ngrok tunnel is created, it displays an interstitial page that can't be removed without paying for an account or adding a custom header, so even with the twilio CLI is running the tunnel, texts to the number do not come through at all 😕

jescalan commented 10 months ago

I was only able to resolve this by getting a paid account with ngrok. It would be ideal if there was some other type of local tunnel that could be used to get started to get zero to one that did not require a paid service initially 🤷‍♂️

github-actions[bot] commented 9 months ago

This issue is stale because it has been open for 30 days with no activity. Please remove stale label or comment or this issue will be closed in 30 days.

github-actions[bot] commented 8 months ago

This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.

github-actions[bot] commented 8 months ago

This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.