I have a luxure HTTP server listening on the hub (similar to the lightbulb-lan-esp8266 example), and I have no issue accessing http://IP:port on my browser.
However, when I http.request to the hub-IP:port, it [string “socket”]:1406: timeout. Is this a bug?
I have no issue if I http.request other devices, but just not the hub IP:port.
I want to know whether the server is running or not.
I was able to replicate the error, you mention. I’m making other tests to see what can be causing the issue.
I’ll also check if there are any restrictions on doing internal requests in the driver with the engineering team, but due to the holidays, their answer might take some time.
driver:register_channel_handler(server.sock, function ()
server:tick()
end)
The server is running in the same thread as lifecycle_handler.init, so, we need to spawn the server on its own thread as follows:
local cosock = require('cosock')
local server = lux.Server.new_with(cosock.socket.tcp(), { env = 'debug' })
server:listen()
cosock.spawn(function()
while true do
server:tick(log.error)
end
end, "server run loop")
server:get('/', function(req, res)
res:send('hello world')
end)
--sample of making the request:
local body, code, headers, msg = assert(http.request(string.format("http://...", server:get_ip(), server.port)))