Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to connect to webhook #19

Closed
leonardodma opened this issue Jul 27, 2022 · 25 comments
Closed

Not able to connect to webhook #19

leonardodma opened this issue Jul 27, 2022 · 25 comments
Labels
question Further information is requested

Comments

@leonardodma
Copy link

leonardodma commented Jul 27, 2022

I followed all the steps in the tutorial section and I was able to send messages, but my webhook endpoint was not verified. I've tried many ways, and the only way that works is using Glitch, as recommended in the API documentation. Do you know any solution that could solve my issue?

@tawn33y
Copy link
Owner

tawn33y commented Jul 27, 2022

Hi @leonardodma,

Two quick questions:

  1. Which version of the library are you using? Version 0.2.0 had some issues in verifying the webhook but this was resolved in version 0.2.1 and 0.2.5.
  2. Can you paste the full error you are getting? e.g. screenshots for the terminal, ngrok (if you're tried using this), etc. I personally haven't used Glitch but if you could share any error messages you are getting, that would be great!

@tawn33y tawn33y added the question Further information is requested label Jul 27, 2022
@leonardodma
Copy link
Author

Hello @tawn33y, thank you for answering so fast!

I'm using the 0.2.5 version of the library and Ngrok 3.0.6.

The server starts running on port 3000 and sends the "hello world" message, just like in the tutorial. Then, I run ngrok HTTP 3000 and it returns a forwarding URL such as https://xxxx-xxxx-xxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxx.sa.ngrok.io. When I try to edit the webhook callbacks' URL, adding /webhook/whatsapp to the end of Ngrok's URL, it returns that it wasn't possible to complete, and the "Webhook Verified" log does not appear in the terminal.

@tawn33y
Copy link
Owner

tawn33y commented Jul 27, 2022

  • When you run the app, does it show a message on the terminal, something like Server running on port ...?
  • After starting your app & ngrok, can you try opening in your browser: https://your-xxx.xx.ngrok.io and see if it returns an error or simply "404"? Also try https://your-xxx.xx.ngrok.io/webhook/whatsapp

@leonardodma
Copy link
Author

It does appear "🚀 Server running on port 3000...". In my browser accessing my Ngrok's URL, GET / returns 404 Not Found, while GET /webhook/whatsapp returns 403 Forbidden.

@tawn33y
Copy link
Owner

tawn33y commented Jul 27, 2022

This shows that it's running fully OK locally, and ngrok is working as well.

Can you share the url you're providing in the App dashboard? I hope it's something like https://xxx.ngrok.io/webhook/whatsapp

@leonardodma
Copy link
Author

It is a little bit different (probably because of the Ngrok version): https://d0f2-2804-431-cff6-9331-241a-5639-ede4-a314.sa.ngrok.io. Anyway, I've tried to use Local Tunnel and it didn't work either.

@tawn33y
Copy link
Owner

tawn33y commented Jul 27, 2022

Ah, seems like there is a new feature that ngrok has introduced to show a browser warning on visiting each page, requiring a user to confirm "Visit page" before loading the page: https://blog.ngrok.com/posts/fighting-abuse-on-the-ngrok-platform

I think what's happening is that Facebook is trying to hit your ngrok endpoint and gets served by html content requiring confirmation, which obviously means that Facebook will fail to verify your webhook.

I wasn't aware that ngrok introduced this. I'm personally using ngrok version 3.0.4 and it doesn't have this feature. Perhaps you can try downloading an earlier version instead?
You can use docker: https://hub.docker.com/r/ngrok/ngrok

Something like:
eg:

docker run -it ngrok/ngrok:3.0.3-debian http 3000

And then try to verify the webhook.

Curious to see if this works.

@leonardodma
Copy link
Author

leonardodma commented Jul 27, 2022

I think you got it! Make totally sense! I will try to run with the 3.0.4 version!

I tried to run docker run -it ngrok/ngrok:3.0.3-debian http 3000 but I got the following log (despite server is still running):

image

@tawn33y
Copy link
Owner

tawn33y commented Jul 27, 2022

How about this:

docker run --net=host -it ngrok/ngrok:3.0.3-debian http 3000 

@leonardodma
Copy link
Author

Running the following command, I was able to connect to the port, but the verification is still happening :(

docker run --net=host -it -e NGROK_AUTHTOKEN=[NGROK_TOKEN] ngrok/ngrok:3.0.3-debian http 3000

@tawn33y
Copy link
Owner

tawn33y commented Jul 27, 2022

What url are you getting now? Can you share? Need to confirm if I'm seeing the "Verify site" browser warning page.

Also, what error are you getting now?

@leonardodma
Copy link
Author

I'm getting this URL: https://7052-187-34-95-187.sa.ngrok.io. It returned the confirmation page firstly, but then got the same error failed to establish a connection to the upstream web service at [localhost:3000](http://localhost:3000/)

@tawn33y
Copy link
Owner

tawn33y commented Jul 27, 2022

Quick question: can you try running this without supplying the auth token?

@leonardodma
Copy link
Author

Sure! https://7652-187-34-95-187.sa.ngrok.io

@tawn33y
Copy link
Owner

tawn33y commented Jul 27, 2022

I'm starting to feel that this might be quicker via a call. Feel free to send a calendar invite for tomorrow. I will respond accordingly if the time doesn't work for me.

@tawn33y
Copy link
Owner

tawn33y commented Aug 8, 2022

Proposed Solutions

(for future reference) There are 4 solutions off the top of my mind for fixing this:

  • Using a bypass header in the request: I posted in Facebook communities asking if it's possible to add an ngrok-skip-browser-warning header in the requests it sends to our webhook, but it seems this is currently not supported: https://developers.facebook.com/community/threads/733910894547222/
  • Paying for ngrok: this allows you to remove the Verify Site interstitial page, but it can be a bit costly ($20 per month).
  • Using ngrok alternative: you can use something like localtunnel, serveo, etc. However, localtunnel also shows a Friendly Reminder prompt page that requires one to confirm before verifying the page. You can use a custom header or pay to remove it.
  • Using an older version of ngrok: see more details below, but note that this means you won't take advantage of any new features or bug fixes offered by the ngrok team.

Using an older version of ngrok

Running ngrok via downloaded zip

  • I tried to reproduce the error: I downloaded ngrok as a zip on a new PC and run: ./ngrok http 3000. This worked perfectly fine and didn't bring a Verify Site interstitial page.
  • I stopped the instance, signed in using an auth token ngrok config add-authtoken <token> and tried running it again. This time the Verify Site interstitial page appeared.
  • I stopped the instance, removed all config files associated with ngrok (~/.ngrok, ~/.config/ngrok/ngrok.yml), and run it again with the assumption that I wouldn't be logged in. On running it however, I now encountered an error that I need to sign up for an ngrok account before continuing (ERR_NGROK_6022). I created fresh config files with no assigned value for auth token, but still got the same error. Perhaps there's another config file I'm missing, but it seems you are unable to go back to running it as a fresh installation.

Running ngrok via docker

  • I run the docker version via: docker run --net=host -it ngrok/ngrok:3.0.3-debian http 3000 but still got the auth error: ERR_NGROK_6022.

Seems a person may need to pay for ngrok or localtunnel for now; at least until Facebook allows the use of custom headers in requests. Any other solutions are most welcome. Will mark this as closed for now.

@tawn33y tawn33y closed this as completed Aug 8, 2022
@guskuma
Copy link
Collaborator

guskuma commented Aug 8, 2022

Hi there! I had no success trying with older version of ngrok (tried 3.0.1) and with ngrok alternatives that doesn't show 'verification page' (pagekite and localtonet). In both alternatives I was able to successfuly browse my local instance without verification page, but when trying to set this as my webhook in FB developers page my instance got untouched and, obviously, I could not set it as my webhook addres.
This might be some FB thing. It's a shame I have to deploy my app to be able to test...

@TGw44
Copy link

TGw44 commented Sep 6, 2022

could you solve this ? @guskuma

@guskuma
Copy link
Collaborator

guskuma commented Sep 6, 2022

Hey @TGw44 I had no luck yet. Next weeks I'll try again and I'll let you know if it works.

@TGw44
Copy link

TGw44 commented Sep 7, 2022

I have good news @guskuma , i made it work without ngrok!

I used Heroku instead.

Here is great video step by step.
https://www.youtube.com/watch?v=HY7Px7wWfq4

Note: i had to change startExpressServer.js line 100

const port = (options === null || options === void 0 ? void 0 : options.port) || 3000;
to
const port = (options === null || options === void 0 ? void 0 : options.port) || process.env.PORT || 3000;

Maybe we can add this alternative in the TUTORIAL @tawn33y

@tawn33y
Copy link
Owner

tawn33y commented Sep 8, 2022

Sure thing, I'll create an issue for this for tracking

@ernsk
Copy link

ernsk commented Dec 6, 2022

Hello everyone, i have read all comments in this issue and i thought finally i found a solution for webhook with using heroku. But when i check the heroku page i see there is no free option anymore. So is there any progress about this situation? How we going to verify?

@ernsk
Copy link

ernsk commented Dec 7, 2022

Ok guys, we can use telebit.io instead of other tunnels. It's works now

@AlexGonzalezInf
Copy link

@ernsk How did u achive with telebit.io, im only watching the reverse form, from a page to a locahost
Can u give me any advise

@shirser121
Copy link

I success to do it with loophole.cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

7 participants