Actually I have created a node server for storing data, and i want to implement web socket connection from nodemcu to node.js server.
For that I'm using SocketIoClient library, following is the code:
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>
#include <SocketIoClient.h>
#define USE_SERIAL Serial
ESP8266WiFiMulti WiFiMulti;
SocketIoClient webSocket;
void event(const char * payload, size_t length) {
USE_SERIAL.printf("got message: %s\n", payload);
}
void setup() {
USE_SERIAL.begin(115200);
USE_SERIAL.setDebugOutput(true);
USE_SERIAL.println();
USE_SERIAL.println();
USE_SERIAL.println();
for(uint8_t t = 4; t > 0; t--) {
USE_SERIAL.printf("[SETUP] BOOT WAIT %d...\n", t);
USE_SERIAL.flush();
delay(1000);
}
WiFiMulti.addAP("SSID", "passpasspass");
while(WiFiMulti.run() != WL_CONNECTED) {
delay(100);
}
webSocket.on("event", event);
webSocket.begin("my.socket-io.server");
// use HTTP Basic Authorization this is optional remove if not needed
webSocket.setAuthorization("username", "password");
}
void loop() {
webSocket.loop();
}
while compiling this code, I'm getting the following error: site
Arduino: 1.8.16 (Windows Store 1.8.51.0) (Windows 10), Board: "NodeMCU 0.9 (ESP-12 Module), 80 MHz, Flash, Legacy (new can return nullptr), All SSL ciphers (most compatible), 4MB (FS:2MB OTA:~1019KB), v2 Lower Memory, Disabled, None, Only Sketch, 115200"
C:\Users\OneDrive\Documents\Arduino\libraries\SocketIoClient\SocketIoClient.cpp: In member function 'void SocketIoClient::beginSSL(const char*, int, const char*, const char*)':
C:\Users\OneDrive\Documents\Arduino\libraries\SocketIoClient\SocketIoClient.cpp:47:50: error: invalid conversion from 'const char*' to 'const uint8_t* {aka const unsigned char*}' [-fpermissive]
_webSocket.beginSSL(host, port, url, fingerprint);
^
In file included from C:\Users\OneDrive\Documents\Arduino\libraries\SocketIoClient/SocketIoClient.h:7:0,
from C:\Users\OneDrive\Documents\Arduino\libraries\SocketIoClient\SocketIoClient.cpp:1:
C:\Users\OneDrive\Documents\Arduino\libraries\WebSockets\src/WebSocketsClient.h:50:10: error: initializing argument 4 of 'void WebSocketsClient::beginSSL(const char*, uint16_t, const char*, const uint8_t*, const char*)' [-fpermissive]
void beginSSL(const char * host, uint16_t port, const char * url = "/", const uint8_t * fingerprint = NULL, const char * protocol = "arduino");
^
exit status 1
Error compiling for board NodeMCU 0.9 (ESP-12 Module).
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.