Forums

IP address used with raw sockets to python-app

Hi there, thanks for a good service so far :-)

I am experimenting with a web-client written in an embedded hardware-system. It seems that whenever I translate the hostname given for my domain, its always returning 50.19.109.98, and doing a socket connection to that IP on port 80 does not work.

Not sure how a real browser connects to the app, but do you have any hints?

That IP address is the our loadbalancer. To make a socket connection to your web app, you'll have to specify the host header so the loadbalancer knows which web app to route your request to.

Hmm. There is no host header in a raw socket so i guess you mean the http request should have the right host header and that the socket connection should go to the ip from above port 80. Right?

Yes. That's right.

Tried different things. No success. I keep getting "bad request" from server. Nothing visible in any of my log files. Not sure if I can do anything to debug...? Can you extract a log based on my ip?

Bad request usually means that your web app expects something that you're not giving it, like a CSRF token. It could also be that your web app is not configured correctly. Can you hit the URL with a browser? Particularly try hitting it in a private browsing session where you haven't hit any of your pages before. You could also try using curl to hit the site and see what the response is.