Node mcu is not working properly

I am working on nodemcu ( I would like to send only a hi message to the problem is when it sends to dweet it closes the connection at once the code is down below:

#include <ESP8266WiFi.h>
//const int ledpin1=5;
//const int ledpin2=4;
//const int ledpin3=15;
//const int input1=13;
//const int input2=14;
//const int input3=12;
//int counter=0;
const char* host =  "";
//// WiFi parameters 
 const char* ssid = "Omar"; 
 const char* password ="11112222" ; 
 //const char* key="omar2009";
 String thingName="omar11";
 String hi="HELLO World";
void setup() {
  // put your setup code here, to run once:

    //Connect to WiFi Network
    Serial.print("Connecting to ");

    WiFi.begin(ssid, password);
    int retries = 0;
    while ((WiFi.status() != WL_CONNECTED) && (retries < 15)){
      Serial.println(F("WiFi conenction FAILED"));
    if (WiFi.status() == WL_CONNECTED){
      Serial.println(F("WiFi connected!"));
      Serial.println("IP address: ");
    Serial.println(F("Setup ready"));

String getDweetString(){
String dweetHttpGet="GET /dweet/for/";
dweetHttpGet=dweetHttpGet +"?HI" + "=" +String(hi);
dweetHttpGet=dweetHttpGet+" HTTP/1.1\r\n"+
               "Host: " +
                 host +
               "\r\n" +
               "Connection: close\r\n\r\n";
  return dweetHttpGet;//this is our freshly made http string request


void sendDweet(){
  WiFiClient client;
  const int httpPort = 80;

  //connect to
  if (!client.connect(host, httpPort)){
    Serial.println("connection failed");
  delay(10); //wait...
  while (client.available()){
    String line = client.readStringUntil('\r');
  Serial.println("closing connection");

void loop() {
  // put your main code here, to run repeatedly:
  Serial.print("Sending dweet to ");
     String hi="HELLO World";

    sendDweet(); //send data to


The ouput is:

Connecting to Omar…
…WiFi connected!
IP address:
Setup ready
Sending dweet to - Share your thing- like it ain't no thang.

closing connection

please could anybody help

OK, first things first.

You need to go and read the forum instructions so that you can go back and modify your original post (not re-post it) - using the “More → Modify” option below the right hand corner of your post - to mark up your code as such using the “</>” icon in the posting window. Just highlight each section of code (or output) from the IDE and click the icon. In fact, the IDE has a “copy for forum” link to put these markings on a highlighted block for you so you then just paste it here in a posting window.

It is inappropriate to attach it as a “.ino” file. People can usually see the mistakes directly and do not want to have to actually load it in their own IDE. And that would also assume they are using a PC and have the IDE running on that PC.

But don’t forget to use the “Auto-Format” (Ctrl-T) option first to make it easy to read. If you do not post it as “code”, it can be quite garbled and is always more difficult to read.

Also tidy up your blank space. Use blank lines only between functional blocks.

FYI - dweet will close the connection on purpose, they do not want open connections taking up bandwidth. This is to help keep the system free and available to everyone.

Max number of dweets you will be able to push per open socket connection is 5.