使用任何类型的Web App都是新手,我一直在尝试慢慢构建一个Facebook Messenger Bot。当我尝试使用ngrok时,我无法访问给定的地址,即:
ngrok http 5000
是我在命令行中输入的内容,它返回以下内容:
ngrok by @inconshreveable
Session Status online
Version 2.1.18
Region United States (us)
Web Interface http://127.0.0.1:4040
Forwarding http://ea986ca5.ngrok.io -> localhost:5000
Forwarding https://ea986ca5.ngrok.io -> localhost:5000
Connections ttl opn rt1 rt5 p50 p90
0 0 0.00 0.00 0.00 0.00
但是当我按照Facebook开发者页面的要求获取地址'https://ea986ca5.ngrok.io‘时,它会说:
The connection to http://ea986ca5.ngrok.io was successfully tunneled to your
ngrok client, but the client failed to establish a connection to the local
address localhost:5000.
Make sure that a web service is running on localhost:5000 and that it is a
valid address.
The error encountered was: dial tcp [::1]:5000: connectex: No connection
could be made because the target machine actively refused it.
我的本地端口有问题吗?谢谢!
发布于 2017-03-28 20:00:13
这对我很有效
ngrok.exe http -host-header=rewrite localhost:<Your Port number>
例如:
ngrok.exe http -host-header=rewrite localhost:5219
我正在使用visual studio 2017,不知道它是否影响了什么。
发布于 2018-10-09 23:06:44
尝试显式设置localhost IP:
用ngrok http 127.0.0.1:5000
代替ngrok http 5000
祝好运!
发布于 2016-12-16 11:55:16
就像@njzk2应该说的那样,如果你没有运行web服务器,那么它就不能工作。如果你还不明白的话,我想让你明白一点。
ngrok所做的是使您的本地服务器(在localhost上运行)对外部世界(互联网的其余部分)可用。就其本身而言,它不是web服务器。因此,对于您的bot开发,您需要有一个web服务器在定义的端口(在您的情况下是5000)上运行。然后,您可以将ngrok指向此端口,以便它将发送到您的公共地址的请求重定向到在该端口上运行的程序。然后,web服务器将接受并处理来自Facebook的请求
https://stackoverflow.com/questions/40598428
复制相似问题