Jor*_*ney 27 https http-tunneling ngrok
使用任何类型的Web应用程序的东西都很新,我一直在尝试慢慢构建一个Facebook Messenger Bot.当我尝试使用ngrok时,我无法访问我给出的地址,即:
ngrok http 5000
Run Code Online (Sandbox Code Playgroud)
是我在命令行中放置的,它正在返回:
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
Run Code Online (Sandbox Code Playgroud)
但是,当我根据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.
Run Code Online (Sandbox Code Playgroud)
这是我本地端口的问题吗?谢谢!
Sas*_*sha 30
尝试明确设置本地主机 IP:
ngrok http 127.0.0.1:5000 代替 ngrok http 5000
祝你好运!
8a9*_*8a9 22
我发现我必须删除 -host-header 部分周围的引号才能使其与最新的 ngrok 版本(2.3.35)一起使用:
ngrok http https://localhost:5001 -host-header=localhost:5001
(目前没有足够的代表对上述任何答案添加评论)
Ken*_*ars 18
正如@ njzk2应该说的那样,如果你没有运行的web服务器那么它就无法运行.如果你仍然感到困惑,我想让你更清楚.
什么ngrok呢,就是让你的本地服务器(在本地主机上运行),以提供给外界(对互联网的其余部分).就其本身而言,它不是Web服务器.因此,对于您的bot开发,您需要在定义的端口上运行Web服务器(在您的情况下为5000).然后,您可以将ngrok指向此端口,以便将发送到您的公共地址的请求重定向到在该端口上运行的程序.然后,Web服务器将接受并处理来自Facebook的请求
小智 17
这对我有用
ngrok.exe http -host-header =重写localhost:
例如ngrok.exe http -host-header =重写localhost:5219
我使用视觉工作室2017不知道它是否影响anthing.
Olt*_*iza 10
步骤 1 - 注册到 ngrok 并在仪表板页面中下载 .exe 文件
第 2 步 - 打开终端并从仪表板复制并粘贴不带 ./ 的行
第 3 步 - 运行您的本地主机
第 4 步 - 如果第 2 步成功完成,请在同一个终端(第 2 步)中粘贴带有 localhost 端口的行
ngrok http https://localhost:44386 -host-header="localhost:44386"
第 5 步 - 复制在终端和 waalla 中生成的 URL。您可以 ping 到它。
如果 <<<<Ngrok 错误 '502 bad gateway'>>>> 将 https 更改为 http,因此步骤 4 将是 ngrok http http://localhost:44386 -host-header="localhost:44386"
尝试如下:
ngrok http 127.0.0.1:8080 -host-header="127.0.0.1:8080"