How to send data from server to A6 GSM module?

Hello! I’m using an A6 GSM module to send sensor data from my board to a server, using HTTP. The board sends a POST message and the server replies with 200 OK.

I want to be able to configure the board from the server. So, I need to send a POST message from the server to the board. The problem is that the server cannot connect to the board.

It is weird, since the connection status is OK (no TCPCLOSED message is generated from the A6 module). Also, in the above situation, the communication works, because the board receives the OK message from the server. It is like the A6 module needs to first send a HTTP message before receiving a message from the server; it cannot receive one without first sending a message.

This is my configuration:
AT+CGATT=1
AT+CGACT=1,1
AT+CIPSTART=“TCP”,“HTTP_SERVER_IP”,80
AT+CIPSEND

Does anybody know what is the problem? Am I misunderstanding something here?

I read that incoming connections are not possible, because the access to Internet is done via NAT. The solution is to use a static IP address.

However, why does data transmission works from server to client (GSM module) when the server responds to the HTTP request sent by the client?

1 Like

@CristianM is right.
You can only initiate connection from module for HTTP. If you use MQTT, you can subscribe and keep TCP connection open to receive configuration data. Or you can configure using SMS.

Hi! But why does data transmission works from server to client (GSM module) when the server responds to the HTTP request sent by the client? Only then it works. Subsequent messages sent by the server are not received by the client. It is like a temporary NAT is made at the operator’s router. The TCP connection is always opened, since I do not get a TCP closed message from the module. Also, why do you say MQTT would work?

Server has a permanent address and servers network allows incoming connections to this fixed address.
In mobile networks they dont have a fixed address and their address keeps changing, thats why the operators dont allow reaching to devices from outside.

Ok, but how is the client able to receive the server http response (as described in the previous messages)?

The response to http post is sent when TCP connection is still active .

But I do not get a TCP closed message from the module after that.

Which TCP closed message? I didnt get you

The A6 module sends the following message over UART when the TCP connection is closed by the module or server: “TCPCLOSED: 0”.