AT+QHTTPPOST response Socket Close error

Hi, I using MC60 based GSM/GPRS/GNSS HAT (SmartElex) module to interface with Arduino Nano board. After sending the AT+QHTTPPOST, CONNECT response is received but when the data is sent just after it SOCKET CLOSE error is received. The recorded response in Hyper Terminal from MC60 is shown in image. The server to which I try to upload data is :

I am using Airtel SIM in the module. What should be the APN, username and password ?

have you solved this issue…?
Actually I’m also using this same module with Arduino UNO and getting the same error code as yours.

Here’s my code:

/*॥ श्री गणेशाय नमः ॥॥ श्री गणेशाय नमः ॥॥ श्री गणेशाय नमः ॥॥ श्री गणेशाय नमः ॥॥ श्री गणेशाय नमः ॥॥ श्री गणेशाय नमः ॥॥ श्री गणेशाय नमः ॥॥ श्री गणेशाय नमः ॥*/
#include <SoftwareSerial.h>

SoftwareSerial mySerial(2,3);
unsigned long lastMillis;

void setup() {
  Serial.begin(115200);Serial.println("");Serial.println("---॥ श्री गणेशाय नमः ॥---");Serial.println("---START---");

    Serial.println("Init Success.");

  sendATcommand("AT" , 2000);
Serial.print("SetUp Done Board Now Ready For Use");

void loop() {
  // put your main code here, to run repeatedly:
      //is the time for a SYS Check? 

      sendATcommand("AT" , 2000);
      sendATcommand("ATE1" , 2000);
      sendATcommand("ATI" , 2000);
      sendATcommand("AT+CMEE=2" , 2000);
      sendATcommand("AT+QIDEACT" , 2000);
      sendATcommand("AT+QIFGCNT=0" , 2000);
      sendATcommand("AT+QICSGP=1, \"\"" , 2000);
      sendATcommand("AT+QIREGAPP" , 2000);
      sendATcommand("AT+QIACT" , 2000);
      sendATcommand("AT+QHTTPCFG=\"requestheader\",1" , 2000);
      sendATcommand("AT+QHTTPCFG=\"responseheader\",1" , 2000);
      sendATcommand("AT+QHTTPURL=23,30" , 10000);
      sendATcommand("" , 2000);
      sendATcommand("AT+QHTTPPOST=300,2000" , 10000);

     // sendATcommand("AT" , 2000);
     // sendATcommand("AT" , 2000);
     // sendATcommand("AT" , 2000);
     // sendATcommand("AT" , 2000);


String sendATcommand(const char *toSend, unsigned long milliseconds) {
  String result;
  Serial.print("Sending: ");
  unsigned long startTime = millis();
  Serial.print("Received: ");
  while (millis() - startTime < milliseconds) {
    if (mySerial.available()) {
      char c =;
      result += c;  // append to the result string
Serial.println();  // new line after timeout.
return result;

I have been successful to send the dummy data and within one-two days expect will be able to send json format. Then, I shall upload the working code to forum.

Till then can you share the dummy so that con work on it >
And for airtel Sim try using APN:

Tried even with Qnavigator but still no hit on the server…:(frowning:

Update on HTTP:
As i was trying to send data to the server always it was showing me http socket close whereas I checked my socket through Advanced Port Scanner there it was showing socket is open.

Update on HTTPs:
Here the request was automatically sent as a GET request even after using the command AT+QHTTPPOST don’t know why. Also after setting the AT+QHTTPCFG=“requestheader”,1 it was not working. whatever i was doing the request was HTTP GET request only…

Successfully sent HTTP Post data to server
Data format was automatically set as.
Content-Type: application/x-www-form-urlencoded

above is the AT commands format to send the data.
No need to enter any header format just directly send your data.

1 Like