lua - Nodemcu 固件无法解析 DNS 或使用 http 客户端。但它连接到一个正常工作的 Wi-Fi 接入点。
问题描述
我可以使用 readthedocs 中的默认 init.lua 连接到 AP。-- https://nodemcu.readthedocs.io/en/master/en/upload/
但是 DNS 不起作用,http 客户端也不起作用。
我编辑了 credentials.lua 以匹配我的 SSID 和密码。它成功连接到我的 WiFi
我验证它与此示例脚本连接:
do
local sta_config=wifi.sta.getconfig(true)
print(string.format("\tCurrent station config\n\tssid:\"%s\"\tpassword:\"%s\"\n\tbssid:\"%s\"\tbssid_set:%s", sta_config.ssid, sta_config.pwd, sta_config.bssid, (sta_config.bssid_set and "true" or "false")))
end
结果:
[NodeMCU-Tool] Connected
[NodeMCU] Version: 2.2.0 | ChipID: 0x813d2b | FlashID: 0x1625c2
[NodeMCU] Running "getapinfo.lua"
[NodeMCU] >----------------------------->
Current station config
ssid:"JohnnyCinco" password:"88888888"
bssid:"00:05:4e:4c:3e:0b" bssid_set:false
[NodeMCU] >----------------------------->
我验证我使用此示例脚本获得了 IP。
ip, nm, gw = wifi.sta.getip()
print("IP Address is:")
print(ip)
print("NM is:")
print(nm)
print("GW Address is:")
print(gw)
结果:
IP Address is:
192.168.61.197
NM is:
255.255.255.0
GW Address is:
192.168.61.1
这是此路由器的正确 IP。
但是一个简单的 DNS 失败了。我使用来自 nodemcu 的示例创建了一个脚本。
net.dns.resolve("www.google.com", function(sk, ip)
if (ip == nil) then print("DNS fail!") else print(ip) end
end)
这就是结果。
[NodeMCU-Tool] Connected
[NodeMCU] Version: 2.2.0 | ChipID: 0x813d2b | FlashID: 0x1625c2
[NodeMCU] Running "getgoogdns.lua"
[NodeMCU] >----------------------------->
null
[NodeMCU] >----------------------------->
即使我从 DHCP 获得了 DNS 服务器。我将其更改为 8.8.8.8 再次测试,我得到了同样的失败。
我可以创建一个 http 服务器并从 LAN 上的其他 WiFi 客户端访问它,这部分工作。但是 DNS 查找和 http 客户端请求都失败了。
此 WiFi AP 适用于所有其他客户端。没有防火墙。只是为了确保我尝试了 2 个不同的路由器。我还尝试了第三个路由器,它有蜂窝互联网而不是我的有线互联网。都失败了。
这是在 nodemcu 版本 2.2.0 上。我已经尝试过 dev 和 master 分支。两者的结果相同。
我尝试在 nodemcu-build.com 上构建,也构建在我自己的 linux 机器上。两者都失败了。
我尝试了来自不同供应商的 4 种不同的 ESP8266 开发板。都失败了。
我错过了什么?我一定缺少一些基本的东西。这太基本了,不能被打破。还是最新的固件坏了?
谢谢J5
解决方案
推荐阅读
- vhdl - 新手问题:VHDL 最佳实践/效率
- c# - 从 .Net Core 控制台应用程序更新 Firebase Firestore 中的文档
- excel - 参考多列删除列中的最后一个单元格
- java - 将 spring-boot 应用程序部署到云代工厂时出现 java.lang.NoSuchMethodException
- node.js - 如何将 nginx 与 adonis 一起使用?
- amazon-web-services - 什么是无服务器中的“hellostepfunc1”
- c# - ListView WPF中的ScrollHeader
- hmmlearn - 使用 hmmlearn 等于零的转换矩阵
- jenkins-pipeline - 在詹金斯管道中安全地传递 iam 角色
- python - 声明一个字符串的元组的最简洁方法