Skip to content

Socket.io don`t connect #2

Description

@erickcrus

My websocket don't connect in arduito to my web server.
my code:

#include <SocketIOClientSecure.h>
const char* server = "my_server_url";
uint16_t port = 8443;
extern String RID;
extern String Rname;
extern String Rcontent;
SocketIOClientSecure socket;
unsigned long now;

void setup(){
     if(socket.connect(server, port)){
         //show green circle on lcd
     }
     else{
         //show red circle on lcd
     }

     now=0000UL;
}

void loop(){
  if(socket.monitor()){
    Serial.print("RID: ");
    Serial.print(RID);
    Serial.print(", Rname: ");
    Serial.print(Rname);
    Serial.print(", Rcontent: ");
    Serial.println(Rcontent+" .");
    //Send ping to server
    if ((millis() - now) > 10000UL) {
      now = millis();
      Serial.println("Sending ping to server...");
      socket.send("device status", "status", "100");
    }
    socket.send("message", "Power", "off");
  }
  else if(socket.connected()){
    //show green circle on lcd
  }
  else{
    socket.connect(server, port);
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions