【问题标题】:NodeMCU don't connect to web-siteNodeMCU 无法连接到网站
【发布时间】:2019-12-17 02:51:44
【问题描述】:

我正在尝试通过以下代码将我的 NodeMCU V3(基于 ESP8266)连接到 http://ya.ru

station_cfg={}
station_cfg.ssid="ssid" -- actual ssid was here
station_cfg.pwd="password" -- and password
server_link = "http://ya.ru"

wifi.setmode(wifi.STATION)
wifi.sta.config(station_cfg)
wifi.sta.connect()

http.put(server_link,
  'hi',
  function(code, data)
    print(code)
    if (code < 0) then
      print("HTTP request failed")
    else
      print(code, data)
    end
  end)

但是连接不成功,输出为:

HTTP client: Response too long (8461)

有什么问题吗? SSID 和密码正确。所有GETPOSTPUT 方法都存在同样的问题。

更新: 嗯,使用 Arduino IDE 中的 C 语言编写的相同脚本一切正常。无论如何,我很奇怪 Lua 解释器不能做这样的请求,但从 C 编译的版本可以。

【问题讨论】:

    标签: http lua esp8266 nodemcu


    【解决方案1】:

    有什么问题?

    HTTP 模块实际上非常准确地告诉您出了什么问题。

    HTTP client: Response too long (8461)
    

    回复过长。 too long 在这种情况下意味着:比它可以处理的更长。看起来您需要根据https://nodemcu.readthedocs.io/en/latest/modules/net/#netsocketsend 使用低级别的net:socket:send()

    【讨论】:

      猜你喜欢
      • 2018-06-14
      • 2016-05-11
      • 1970-01-01
      • 1970-01-01
      • 2016-05-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多