Using telnet under windows to test HTTP - http

I'm learning http, and trying to use telnet to send my own http requests.
In the command prompt, I entered:
telnet google.com 80
Result:
The screen is cleared and I see a blinking cursor.
1. Why don't I see any indication that I'm connected?
Now, trying to type an http command (get index.html...)
I see the cursor moving to the right as I type, but I don't see the letters appear on the screen. Only blanks.
2. Why is that?
(Using windows7 64 bit)

Why don't I see any indication that I'm connected?
The blinking cursor on a blank screen is the indication you are connected. Otherwise, you'll get an error describing why you couldn't connect.
I see the cursor moving to the right as I type, but I don't see the letters appear on the screen.
Use localecho.
an http command (get index.html...)
That is not a valid HTTP request, you should at least type something like this, followed by two Enters:
GET / HTTP/1.1
Host: google.com
Look at the RFC on how to construct an HTTP request and see some samples.

Related

Sending HTTP request

I am trying to upload data from an Arduino to data.sparkfun.com, but somehow it always fails. To make sure that the HTTP request I am sending is correct, I would like to send it from a computer to the server and see if it uploads the correct values.
According to some examples, the request should be formulated like this:
GET /input/publicKey?private_key=privateKey&dht1_t=24.23&dht1_h=42.4&dht2_t=24.48&dht2_h=41.5&bmp_t=23.3&bmp_p=984021 HTTP/1.1\n
Host: 54.86.132.254\n
Connection: close\n
\n
How do I send this request to the server from my computer? Do I just type in the terminal? Im not sure where to start.
Have a look at curl which should be able to handle your needs.
Even easier and more low level is netcat (here is an example on SO)

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.
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.

telnet protocol: response to break

I've got a C++ server application which provides a listening TCP port for support personnel to connect to. They can issue commands and get responses. It's working fine from the application perspective.
My problem arises when they use telnet(1) to connect, and if they (for some reason) type a ^C. My server sees the parsed control characters that telnet sends me, and I can ignore or process them as I see fit. But the telnet client itself goes into some state where it stops outputting my server's responses to the client's screen.
I know I could either 1) tell them not to use telnet or 2) tell them to do a toggle autoflush inside the telnet app, or via ~/.telnetrc or whatever. But what I would prefer to do, if possible, is respond in the server with the correct protocol sequence to get their client to do the right thing with the text that follows. This just feels like it'd be a better UX for them. Their job sucks enough as it is.
Is this possible? I've been through the RFC and it's not clear. From my own past use of telnet in the past, this feels like it's doable, but my memory may be fuzzy.
The idea behind IAC DO TIMING-MARK (FF FD 06) is to suppress the output of the process that is to be interrupted by the IAC IP interrupt process (FF F4) command. In this way the telnet client program hides all output from the user until it receives a proper timing mark or notification that timing mark is not supported by the server.
You may or may not respond or take action to the IAC IP but you have to respond to IAC DO TIMING-MARK. The easiest way in your case is to respond that you ignored it by IAC WONT TIMING-MARK (FF FC 06) and the client should continue displaying all the output normally.
If you really terminate the current job, then you should flush your buffers and then respond with IAC WILL TIMING-MARK, which means that the client will discard all server's output from the moment the user pushed ^C to the place in the stream where it finds the IAC WILL TIMING-MARK (FF FB 06).

error +HTTPACTION:0,601,0

I m trying to access a website using sim900 GSM module.
This is the list of commands
AT+CSQ
+CSQ: 16,0
OK
AT+HTTPINIT
OK
AT+HTTPPARA="CID",1
OK
AT+HTTPPARA="URL","www.google.com"
OK
AT+HTTPACTION=0
OK
+HTTPACTION:0,601,0
AT+HTTPACTION=0
OK
+HTTPACTION:0,601,0
Unable to access google. 601 code shows Network error.
How to get rid of this error?
You need to setup the connection to the bearer. Here are the minimum setup commands that have worked for me (based on trial/error and searching around on the internet).
AT+SAPBR=3,1,"APN","wap.cingular"
AT+SAPBR=1,1
The correct value for the APN may be different for you, depending on your network and service provider. I'm using AT&T prepaid SIM cards. Once that's working, then you can do the HTTP setup commands as you already have...
AT+HTTPINIT
AT+HTTPPARA="URL","http://www.google.com"
AT+HTTPACTION=0
Status codes above 600 (and some in the 500 range) are unassigned in the HTTP standard. In the AT command manual for the SIM908, status meanings are given in the notes on the HTTPACTION command:
600 Not HTTP PDU
601 Network Error
602 No memory
603 DNS Error
604 Stack Busy
You can query the bearer connection status of CID 1 with AT+SAPBR=2,1 and the related parameters with AT+SAPBR=4,1. You can also check that you're attached to the GPRS network with AT+CGATT?. If everything indicates that you are connected and you are still getting a 601 status code, then check that your service plan has data and that it hasn't run out. I have found that even when my account has a few hundred k of data showing on the balance that I start to get a 601 status until I add more data to my prepaid phone plan. If the SIM module has been on the whole time and you add more data, you'll need to close and re-open your connection (AT+SAPBR=0,1 followed by AT+SAPBR=1,1) and then your HTTP* commands will start working again without having to set the HTTPPARA settings again and without having to restart with HTTPINIT.
I have found that when an http call is made to an https only website it will throw a 601 error on the sim. Beware some sim devices have ssl and some don't. Use AT+HTTPSSL=? to interrogate. device with ssl will respond like, 'HTTPSSL 1'. If you get an error your device doesn't have ssl. This took some work with the factory for me to determine this.
You must also use to hit ssl site. I am using the wifi101 ssl client.
fona.setHTTPSRedirect(true);
dy3
I have encoutered this error as well. The cause of the problem may be that there is not enough money in the phone number account. You may check it.
601 is some custom implemented Error code.
Here is the list of standard HTTP Status codes
+HTTPACTION:0,601,0
The above AT response code (601) for HTTP session start indicates that
there is a network error. Then make sure that the PDP context is setup
properly.
source
https://m2msupport.net/m2msupport/at-command-for-http-functions-for-remote-server-data-access/
I have spent many hours with this module right now.
My experience is that when you dont get a 200 reply from remote server, you should check IP address to verify you are still on the network sendng a ping to a working server (AT+CIPPING="XX.XX.XX.XX").
If it succeeds: Try AT+SAPBR=2,1 and AT+CIFSR. You should get same address for both commands.
If you dont get same address, login again to the netword/service with AT+CIPCSGP=1, "yourapn.com", "user", "password".
If nothing works, power down the module. Wait a couple of minutes, and restart again.
Just in case someone is affected by this problem and stumbles on this post 4 years later: in my case the module had a small "sticker" type antenna and it got somehow damaged.
I could connect to the network but when I tried to use HTTP over the GPRS networks I only got return code 601 (network error) or 603 (failed to resolve DNS).
Once I replaced the antenna with a new one, everything worked perfectly.
Again, in case somebody has the same problem. In my case it was a typo in url:
AT+HTTPPARA="URL"," http://www.google.com"
Did you notice the space before http? For several hours, I didn't notice it too.
Usually after this command AT+SAPBR=3,1,"CONTYPE","GPRS" you enter your "APN", "USR" & "PWD" details also using SAPBR=3,1 etc. These details must match the SIM card / mobile phone provider.
Then it is recommended to check that your device has now received an IP address. Sometimes this is not straight away. Use AT+SAPBR=2,1 to query and this will return your IP address which you should check for confirmation.
Once you have IP address you can enter AT+HTTPINIT, AT+HTTPPARA="CID",1 etc.
Now to use GET you have to include a "?" after the URL to provide your php script with a key=value pairing.
Thus in your case it is something like, AT+HTTPPARA="URL","http://<Public_Ip_Address>:8080/folder/savedata.php?A=1001" where A is the key and 1001 is the value.
Now send the AT+HTTPACTION=0 and you should get a +HTTPACTION: 0,200,1000 response where 200 is the OK and 1000 is the payload size. AT+HTTPREAD will allow you to read the response if it is required.
Change URL. 601 is a URL has been moved. Is a redirect.

Blackberry 9000 getting HTTP error 406 When using WiFi

So, I have a Blackberry 9000 application doing simple networking using HttpConnection. Everything works fine normally, when I go to urls of the form:
http://url.com
But I've discovered that I need to test this in wifi only situations (that is, without a BES or equivalent in sight). After some digging, I discovered that I need to add:
;interface=wifi
To all of my URLS, of the form:
http://url.com;interface=wifi
However, I'm noticing that this does not actually work, it gives me back a HTTP error 406. Which according to wiki is a:
406 Not Acceptable
The requested resource is only capable of generating content not acceptable according to the Accept headers sent in the request.[2]
Am I doing something completely wrong? Does Blackberry wrap wifi only requests in headers that require particularly formatted websites?
As explained on this page, you also need add "deviceside=true" to the URL.
To specify that the underlying TCP
connection should be opened directly
from the handheld, set this parameter
to "true". Specify "deviceside=false"
when receiving or sending data through
the BlackBerry MDS Connection Service.
So your full URL would be:
http://url.com;interface=wifi;deviceside=true

Resources