An archive of community.esquilo.io as of Saturday January 26, 2019.

Problem with HTTPC not able to connect

softwarejanitor

I have some code that is not working like I think it should...

require("HTTPC");

local http = HTTPC("api.mlab.com", 443);

When run that generates an error message "cannot connect to host".

However, I am able to do this in a browser:

https://api.mlab.com/api/1/login?apiKey=...

And it works...

I've tried various combinations to try to make it work based on the HTTPC documentation but no luck. I think it may be because if I just try https://api.mlab.com/ in the browser it gives me a not authorized error. I've tried putting in the apiKey parameters, etc., when instantiating the HTTPC object but I haven't gotten it to work.

robertjensen

Try playing with the ssl argument. I had experience where I needed to specify it as false even though the documentation says that false is the default for ports other than 443. Maybe the default value is not working for you.

softwarejanitor

No bueno. I tried the ssl value both true and false and it made no difference.

patrick

Have you tried appending the api/1/login?apiKey=<key> to api.mlab.com/ in the HTTPC instantiation? Maybe that's what you meant at the end of your first post. Just clarifying.

softwarejanitor

Yep, tried several variants of that.

softwarejanitor

That almost works. I get an http that I can do a get on (rather than null), but when I try to get from any of their services I get an error message telling me I am trying to send a non-SSL query to an SSL server.

If there was a way to shift gears to make it do the connection non-SSL and then go to SSL or something like that maybe it would work.