Having trouble with socket.http

I’m retiring a computer and moving everything to another.

On my old machine, I have a PHP script that uses the MSAPI to speak text on behalf of my Vera.

On the new machine, I’m trying to reproduce things using Girder’s text-to-speech library. I’ve got everything working in Girder and can kick off text from Perl scripts and PHP, but not from Vera.

This should really only involve changing the URL where I point my speech function (in startup LUA) to the new URL.

old:
durl = “http://192.168.1.100/say/?t=” … t

new:
durl = “http://192.168.1.110/gir/speak.lhtml?t=” … t

Then I kick off the speech with

		http = require("socket.http")
		local  body, code, headers, status = http.request(durl)

But the new isn’t working.

I’ve tried looking at the response using

luup.log(body)
luup.log(code)

but they log null for both working and non-working code, so I obviously don’t understand what’s returned.

I have the script in Girder returning text so that Vera knows it’s not an empty return. I’ve looked at the headers using Firefox and Girder is returning a 200 OK header.

Can anyone point me in the right direction?

Here’s a simplified version that I’m using in my “test LUUP code”:

function say(text)
	
		t = "this%20is%20a%20test"

		-- this is the OLD URL
		-- durl = "http://192.168.1.100/say/?t=" .. t	
		-- This is the new
		durl = "http://192.168.1.110/gir/speak.lhtml?t=" .. t
		
		http = require("socket.http")
		http.TIMEOUT = 10
		local  body, code, headers, status = http.request(durl)
	
end
say()

What does a command that works from a browser look like?

http://192.168.1.110/gir/speak.lhtml?t=this%20is%20a%20test

Your web server must be sensitive to the headers that are sent. Clearly it does not like the default headers sent by the socket.http.request function.

SSH-ing into my Vera, I can tap the URL with wget and it works, but Lua’s socket.http isn’t working.

My simplified code I’m testing now:

durl = "http://192.168.1.110/gir/speak.lhtml"
http = require("socket.http")
local body, code, headers, status = http.request(durl)
I can tap the URL with wget and it works
Did you try [b]luup.inet.wget(...)[/b]?

inet.wget works!

But the reason I was using http.request was to set the timeout. With these scripts, there’s no need to wait for the speech to complete, so a “tap” has been working. And it keeps Vera from waiting for the speech to complete.

If I recall, you can’t set timeout with inet.wget.

luup.init.wget(url,timeout)

If you don’t include a timeout argument, it defaults to five seconds.

Ron - the programmer behind Girder found and fixed a bug in their HTTP server. There was a case-sensitivity issue. Thanks for everyone’s help on this. It helped me get complete info to Ron to get things fixed.