出现DNS失败,是什么原因,如何解决?

作者:coldfish | 更新时间:2016-11-18 | 浏览量:2000

系统能正常运行大约半小时,然后出现以下错误。

DNS retry 1!
DNS retry 2!
DNS retry 3!
DNS retry 4!
DNS Fail!
如何解决呢?


评论:共7条

贝壳物联 评论于:2016-11-18 16:13:27
请详细说明一下问题出现的情景。什么系统,运行的什么代码?
coldfish 评论于:2016-11-18 17:04:34
DEVICEID = "939"
APIKEY = "0XXXXXXXe"
INPUTID = "875"
host = host or "www.bigiot.net"
port = port or 8181
uOnline = 0
LED = 8
gpio.mode(LED,gpio.OUTPUT)
local function run()
local cu = net.createConnection(net.TCP)
cu:on("receive", function(cu, c)
print("R:"..c)
r = cjson.decode(c)
if r.M == "say" then
if r.C == "play" then
gpio.write(LED, gpio.HIGH)
ok, played = pcall(cjson.encode, {M="say",ID=r.ID,C="LED turn on!"})
cu:send( played.."\n" )
end
if r.C == "stop" then
gpio.write(LED, gpio.LOW)
ok, stoped = pcall(cjson.encode, {M="say",ID=r.ID,C="LED turn off!"})
cu:send( stoped.."\n" )
end
firstidx, lastidx, key, value = string.find(r.C, "(%a+)%s+(%d+)")
if key == "open" then
print(key,value)
time=tonumber(value)
gpio.write(LED,gpio.HIGH)
tmr.alarm(2,time*1000,0,function()
gpio.write(LED,gpio.LOW)
end)
ok, stoped = pcall(cjson.encode, {M="say",ID=r.ID,C="LED turn off!"})
cu:send("open "..value.."\n" )
end
end
if r.M == "checkinok" then
pwm.close(signLed)
pwm.setup(signLed,1,1000)
pwm.start(signLed)
uOnline=1
end
end)
cu:on('disconnection',function(scu)
cu = nil
--停止心跳包发送定时器,5秒后重试
tmr.stop(1)
pwm.close(signLed)
pwm.setup(signLed,1,512)
pwm.start(signLed)
uOnline=0
tmr.alarm(6, 5000, 0, run)
end)
cu:connect(port, host)
ok, s = pcall(cjson.encode, {M="checkin",ID=DEVICEID,K=APIKEY})
if ok then
print(s)
else
print("failed to encode!")
end
cu:send(s.."\n")
tmr.alarm(1, 30000, 1, function()
temp=adc.read(0)
str="{\"M\":\"update\",\"ID\":\""..DEVICEID.."\",\"V\":{\""..INPUTID.."\":\""..temp.."\"},\"K\":\""..APIKEY.."\"}\n"
if uOnline==1 then
cu:send(str.."\n")
print(str)
else
cu:send(s.."\n")
-- print(s)
end
end)
end
run()


就是这段代码,运行一段时间后就报上面的错误
coldfish 评论于:2016-11-18 17:06:40
我猜是不是原先的数据间格太小,或者没有设置成公开?
coldfish 评论于:2016-11-18 17:12:58
NudeMCU,带json,adc,wifi,uart,file等模块
贝壳物联 回复于:2016-11-18 21:26:17
回复 @coldfish:试试直接用贝壳的IP地址,不用域名
host = host or "121.42.180.30"
coldfish 回复于:2016-11-24 10:09:28
回复 @贝壳物联:好的,有可能是域名解析有问题
spzmmd 评论于:2017-08-12 09:24:29
我出现这个问题都是网络不顺,换个好网就没事了
返回顶部