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 :
http://crm.zeusmobility.com:5100/api/consumer/batteryLog.

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---");
mySerial.begin(9600);

    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, \"airtelgprs.com\"" , 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("http://smartdwelliot.in" , 2000);
      sendATcommand("AT+QHTTPPOST=300,2000" , 10000);
      

     // sendATcommand("AT" , 2000);
     // sendATcommand("AT" , 2000);
     // sendATcommand("AT" , 2000);
     // sendATcommand("AT" , 2000);
      Serial.println();

}

String sendATcommand(const char *toSend, unsigned long milliseconds) {
  String result;
  Serial.print("Sending: ");
  Serial.println(toSend);
  mySerial.println(toSend);
  unsigned long startTime = millis();
  Serial.print("Received: ");
  while (millis() - startTime < milliseconds) {
    if (mySerial.available()) {
      char c = mySerial.read();
      Serial.write(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: airtelgprs.com


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