As the title says... Chat on...

User avatar
By FrankX
#64306 I am using net.socket:send() to retrieve web content.
Occasionally there is no response without receiving a disconnect.
This leaves my application waiting indefinitely.
I have created a timer which is re-triggered every successful reception.
Bu what should I do in the timeout case?
If I reconnect the application stops: PANIC: unprotected error in call to Lua API (already connected)
How do I know if the connection is still open?
More in general: how can I deal with such errors (PANIC), preventing an application failure like shown above?
User avatar
By FrankX
#64435 I tried using pcall() but still program execution stops in the same way.
It seems pcall() is not able to catch any error.

Example:
Code: Select allif pcall(print(a..a)) then
    print("OK")
else
    print("NG")
end

Execution stops in the same way as without pcall().

Could this be a NodeMCU firmware issue?

Update
Answer to myself: no :-)
I was using pcall() incorrectly.
This works:
Code: Select allif pcall(function() print(a..a) end) then
    print("OK")
else
    print("NG")
end