Search code examples
httpherokuat-commandiotmodem

HTTP 505 error when requesting Heroku apps w a cell module


I'm trying to use the Telit GE910 cell module to make HTTP requests over the cell network. I've connected it via a FTDI board to my computer's USB port and am sending it AT commands via the terminal. I'm using the AT commands to successfully open a socket in command mode and send the HTTP request.

AT#SD=1,0,80,"google.com",0,0,1
OK
�AT#SSEND=1
> HE�AD� /� HTT�P/1.1


OK

SRING: 1

I don't understand why these � are turning up. When making requests for google.com this is fine but anything hosted on Heroku gives me a 505 error.

HTTP/1.1 505 HTTP Version Not Supported
Connection: close
Server: Cowboy
Date: Tue, 26 Apr 2016 20:39:34 GMT
Content-Length: 0

I've read in one or two forums that this 505 response is specific to Heroku and has to do with incorrect spacing in the HTTP request. I suspect the unrecognized characters are creating the problem. What is going on? They consistently turn up before 'A', 'space', and 'P'; there may be other letters also but those are the ones that I've seen.


Solution

  • Ok, I have figured out (I think) why I was getting a 505 response. Then I started getting a 400, but I figured that out too!

    In the application note for socket dials from Nimbelink (which is a vendor that uses the Telit cell modules--I have one of their modules which has the Telit GE910 on it) it says that after you enter your HTTP request (e.g. GET / HTTP/1.1) you're meant to hit ctrl+j twice to signal the end of the request.

    Well, I started doing all of my serial communication in CoolTerm so that I could see the HEX I was sending. (My hope was I could catch the � characters--I didn't, in fact they don't turn up in CoolTerm.) ctrl+j results in a single line feed (HEX: 0A). According to HTTP documentation, to signal the end of a line you're meant to use carriage return line feed (HEX: 0D 0A). (Heroku also says it has to be formatted like this.) This is what I send when I hit enter. So if I end GET / HTTP/1.1 with enter twice, the request gets though. Though even a HEAD / HTTP/1.1 request to heroku.com comes back as a 400. But that's up next:

    According to RFC (which I found out here) HTTP 1.1 requires a Host. So if I do the whole thing with the right line endings

    GET / HTTP/1.1
    Host: heroku.com 
    

    it works! It also works for posting to my server.