Page 1 of 2
LuaSocket returns nil with http.request
Posted: Thu Aug 18, 2016 11:52 pm
by Croutonix
Wiki says LuaSocket is implented in love2d so I tried example code from LuaSocket webpage
Code: Select all
local http=require'socket.http'
body,c,l,h = http.request('http://w3.impa.br/~diego/software/luasocket/http.html')
print('status line',l)
print('body',body)
Returns
I tried multiple examples, I always get nil.
Do I need to allow love in firewall or something like that?
Re: LuaSocket returns nil with http.request
Posted: Fri Aug 19, 2016 1:26 am
by Positive07
Can't replicate with that example, do you have a LÖVE file or something that actually errors?
Re: LuaSocket returns nil with http.request
Posted: Fri Aug 19, 2016 12:55 pm
by Croutonix
Re: LuaSocket returns nil with http.request
Posted: Fri Aug 19, 2016 1:12 pm
by zorg
That has the line
Code: Select all
body, c, l, h = http.request("shttp://w3.impa.br/~diego/software/luasocket/http.html")
Never heard of an shttp protocol.
Optionally, if that's really not the issue, then i'd suggest not using a fragmentary conf.lua file, since it may affect what modules are loaded and what aren't. (May be wrong on this, but i do remember this being an issue to someone before)
Re: LuaSocket returns nil with http.request
Posted: Fri Aug 19, 2016 1:30 pm
by Croutonix
Still returns nil with http...
What do you mean by not fragmentary?
I need to add love.conf function to main.lua?
Re: LuaSocket returns nil with http.request
Posted: Fri Aug 19, 2016 1:39 pm
by zorg
I mean that your love.conf function only sets the console. It's basically missing everything else that's shown
on the wiki, though as i said, i might be wrong on this one.
Re: LuaSocket returns nil with http.request
Posted: Fri Aug 19, 2016 1:47 pm
by Tjakka5
If you log 'c' it should tell you which error code you're getting. You can go from there.
https://en.wikipedia.org/wiki/List_of_HTTP_status_codes
Re: LuaSocket returns nil with http.request
Posted: Fri Aug 19, 2016 3:04 pm
by bartbes
Croutonix wrote:
Do I need to allow love in firewall or something like that?
If you have a firewall that's blocking love, that would do it.
zorg wrote:I mean that your love.conf function only sets the console. It's basically missing everything else that's shown
on the wiki, though as i said, i might be wrong on this one.
Yeah, that page lists the defaults, you only need to set whatever you're overriding.
I think it's failing at an earlier state, but according to the luasocket docs...
In case of failure, the function returns nil followed by an error message.
Which would end up in 'c'.
Re: LuaSocket returns nil with http.request
Posted: Fri Aug 19, 2016 3:41 pm
by Croutonix
c returns closed, which is not in the list of status codes? What does it mean?
I added it to firewall filter, nothing changed.
Re: LuaSocket returns nil with http.request
Posted: Fri Aug 19, 2016 3:50 pm
by zorg