anton
July 9, 2024, 11:08am
1
I am trying to send data to an api using KTCPSTART
AT+KTCPCFG=1,0,“myurl.co.uk ”,80
+KTCPCFG: 1
OK
AT_KTCPSTART=1
CONNECT
now I don’t know what to do.
The manual says “Send data with KPATTERN string at the end. e.g. “GET / HTTP/1.0 --EOF–Pattern–”
I know I need to send some data followed by --EOF–Pattern–" but I don’t know how to structure the first part of the data. I cannot find an explanation of this anywhere.
the api command that I would type into postman is http://myurl.co.uk/api/get_test
so what should I send after the CONNECT to achieve the same thing ?
jyijyi
July 9, 2024, 11:30am
2
You need to send http get protocol
Be careful you need to send double 0xd 0xa to get response
anton
July 9, 2024, 12:29pm
3
Thanks for that - but I still cant get it to work.
testing using reqbin I can send the api command ok.
using the hl7800 AT commands I get a KTCP_NOTIF of 1,4 which indicates the connection has been closed by the server or remote client.
When I test using reqbin it works fine which suggests to me that the connection is being closed by the remote client (ie the modem?) and not by the server. Why would this be ?
Do you have any idea why this isn’t working ?
Can you try with http get request to get a simple html file?
anton
July 9, 2024, 2:05pm
5
I have and I get the same result
What have you sent after CONNECT?
I think there is no need to send --EOF–Pattern–
anton
July 9, 2024, 3:03pm
7
if I don’t send the eof pattern I get the following
AT+KTCPSTART=1
CONNECT
GET /ok.html HTTP/1.1
Accept: /
Host: myurl.co.uk
HTTP/1.1 400 Bad Request
Server: awselb/2.0
Date: Tue, 09 Jul 2024 14:57:53 GMT
Content-Type: text/html
Content-Length: 122
Connection: close
400 Bad Request
400 Bad Request
NO CARRIER
+KTCP_NOTIF: 1,4
AT+KTCPSTART=1
CONNECT
OK
with the EOF pattern …
AT+KTCPSTART=1
CONNECT
GET /ok.html HTTP/1.1
Accept: /
Host: myurl.co.uk
–EOF–Pattern–
OK
+KTCP_DATA: 1,272
+KTCP_NOTIF: 1,4
+KTCP_DATA: 1,272
+KTCP_NOTIF: 1,4
Then you need to check with server why there is bad request
You can enter the same in tera term in pc and see if bad request is received
anton
July 9, 2024, 3:14pm
9
I don’t know how to check with the server - I can only test it using other methods and when I try using postman or reqbin it works fine - what can be missing ?
jyijyi
July 9, 2024, 3:15pm
10
You can enter the same in tera term in pc and see if bad request is received
If it is the same, then that means your protocol has problem
anton
July 9, 2024, 3:42pm
11
Yes it is the same - any ideas on where I should look to resolve this ?
jyijyi
July 9, 2024, 3:46pm
12
As said before, this is not module issue, you need to study the http protocol and make it work in pc first
jyijyi
July 9, 2024, 4:23pm
13
I just tried the following with your server in PC, no problem is found:
Connecting to 78.141.234.188 ...
Connected to 78.141.234.188
GET /index.html HTTP/1.1{0D}{0A}Host: 78.141.234.188{0D}{0A}{0D}{0A}HTTP/1.1 200 OK{0D}{0A}Date: Tue, 09 Jul 2024 16:22:21 GMT{0D}{0A}Server: Apache/2{0D}{0A}Upgrade: h2,h2c{0D}{0A}Connection: Upgrade{0D}{0A}Last-Modified: Sat, 04 Mar 2023 19:49:41 GMT{0D}{0A}ETag: "2f-5f6185cde0bc4"{0D}{0A}Accept-Ranges: bytes{0D}{0A}Content-Length: 47{0D}{0A}Vary: User-Agent{0D}{0A}Content-Type: text/html{0D}{0A}{0D}{0A}<html>webserver is functioning normally</html>{0A}
Connection closed
anton
July 9, 2024, 4:47pm
14
Did you run that from teraterm ?
did you enter {0D}{0A} or did you press return ?
I have had some success trying it from telnet but not from teraterm
jyijyi
July 9, 2024, 4:49pm
15
in tera term, you need to set the following:
in this case, when you type ENTER key, it will send 0xd 0xa
anton
July 9, 2024, 5:05pm
17
That was it! cr + lf solved the problem.
Thanks so much for all your help and patience - much appreciated.