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)))
I’m afraid I’m unable to get it to work. I’m still getting [string "socket"]:1406: timeout.
I’ll send you a DM.
RBoy
(www.rboyapps.com - Making SmartThings Easy!)
7
Has anyone noticed that the luxure library included with edge is different from the GitHub version.
If I try to use response:status(200):send() with the ST luxury library it fails with 500 http error (something about trying to call a number as a function). If I try using the GitHub luxure and try to cosock asyncify it, it fails with some socket error.
RBoy
(www.rboyapps.com - Making SmartThings Easy!)
9
Thanks, yes I did that and also raised this issue with the dev. I can’t find the status method in the source code. Maybe a typo in the doc - the source seems to indicate that it defaults to error 500 when there’s an internal error
RBoy
(www.rboyapps.com - Making SmartThings Easy!)
10
I’ve found an issue with this and hub firmware 0.46.004, infact I found many issues with the 46.4 firmware including cosock issues (everything is working great with 45.11 firmware). Are you by any chance running firmware 46.4?
I am so glad I found this thread - I was going nuts. I originally used the same example to set up a local luxure server on the hub, and it was definitely working fine a couple months ago. But a few people have started posting about having issues, and today I finally got around to testing it and discovered trying to hit my POST endpoint from Postman, the request just spins endlessly, with nothing showing in the CLI logs.
I changed the server spin up flow to mirror the example posted by @nayelyz above, and it works again.
I am not exactly sure what this means, but I’m guessing something changed with cosock/luxure within the last month or two, so if that sample code hasn’t been update, it might need to be.