How to send data with KTCPSTART

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 ?

You need to send http get protocol

Be careful you need to send double 0xd 0xa to get response

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?

I have and I get the same result

What have you sent after CONNECT?

I think there is no need to send --EOF–Pattern–

if I don’t send the eof pattern I get the following :-1:

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

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 ?

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

Yes it is the same - any ideas on where I should look to resolve this ?

As said before, this is not module issue, you need to study the http protocol and make it work in pc first

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

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

in tera term, you need to set the following:
image
in this case, when you type ENTER key, it will send 0xd 0xa

That was it! cr + lf solved the problem.

Thanks so much for all your help and patience - much appreciated.