MQTT over TCP - Connection is getting closed immediately

I have completed my IOT MQTT task in Arduino successfully.But when I tried same task in PIC18F4550,TCP connection is getting closed immediately.
I have attached my code and Image of my problem.
Please help me if you have any Idea about it.

Main code.docx (14.1 KB)
Add.h.docx (13.0 KB)
Configuration_header_file.h.docx (11.5 KB)
LCD.h.docx (11.1 KB)
pic_serial.h.docx (11.8 KB)
SIM900TCPClient.h.docx (11.0 KB)


Hi Sukanya,
You might want to try looking at this code which @mbari - Peter shared recently. Base your code on it.

Also i think you need to add more delay after each command, like, wait for the connect response before sending the CIPSEND command.