Thanks for the quick response earlier today.
I incorporated the code into my already existing error handling code.
the modem connects to the server but the connection is closed immediately as per this video
the code I am using can be found in a repository Here
Kindly let me know what could be wrong with the code since it worked with sim900 in Ravi’s Tutorial.