khoih-prog / WebSockets2_Generic

A WebSocket Server and Client library for Arduino, based on RFC6455, for writing modern Websockets applications. Now support ESP8266, ESP32 (including ESP32-S2 Saola, AI-Thinker ESP-12K, WT32_ETH01, etc.), nRF52, SAMD21, SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, Teensy, RP2040-based, etc. boards, with WiFiNINA, Teensy 4.1 NativeEthernet/QNEthernet, Ethernet W5x00 / ENC28J60 / LAN8742A / LAN8720, ESP8266 / ESP32-AT modules/shields, as well as SINRIC / Alexa / Google Home
GNU General Public License v3.0
81 stars 30 forks source link

Uploading and running example of ESP "Minimal-Esp32-Client" error [ 4159][E][WiFiClient.cpp:313] setSocketOption(): fail on -1, errno: 9, "Bad file number" #53

Closed yoavshah closed 1 year ago

yoavshah commented 1 year ago

Describe the bug

I tried to run the example of ESP32 called "Minimal-Esp32-Client" (and other examples, but this one is the easiest to reproduce), then the monitor printed

[ 4159][E][WiFiClient.cpp:313] setSocketOption(): fail on -1, errno: 9, "Bad file number"

and then Not Connected!

Steps to Reproduce

I am using visual studio code with PlatformIO and created a new project of ESP32 on Arduino framework. Just put the example code "Minimal-Esp32-Client" with your wifi ssid and password and the websocket server to connect to and it will do it

PlatformIO version: Core 6.1.4 - Home 3.4.3 Core Version: I am not sure, i think Arduino-mbed Board type: ESP32 Contextual information: I tried to run the example code Using Windows 10

Screenshot 2022-10-19 234205

yoavshah commented 1 year ago

When running in ArduinoIDE I still got the error message, but I could print more debug line 2

khoih-prog commented 1 year ago

Do some basic research, test some more examples before posting any issue.

I'm closing the issue unless you prove this is a bug of this library.

As you're using ESP32, I suggest you post any issue next time in ArduinoWebsockets library

khoih-prog commented 1 year ago
Start Minimal-ESP32-Client on ESP32_DEV
WebSockets2_Generic v1.13.0
..Connected to Wifi, Connecting to WebSockets Server @192.168.2.30
[WS] WebsocketsClient::generateHandshake: base64Authorization = 
[WS] WebsocketsClient::generateHandshake: handshake = GET / HTTP/1.1
Host: 192.168.2.30
Sec-WebSocket-Key: MDEyMzQ1Njc4OWFiY2RlZg==
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Version: 13
User-Agent: TinyWebsockets Client
Authorization: Basic 
Origin: https://github.com/khoih-prog/Websockets2_Generic

[WS] WebsocketsClient::connect: base64Authorization = 
[WS] WebsocketsClient::generateHandshake: key = Upgrade
[WS] WebsocketsClient::generateHandshake: value = websocket
[WS] WebsocketsClient::generateHandshake: key = Connection
[WS] WebsocketsClient::generateHandshake: value = Upgrade
[WS] WebsocketsClient::generateHandshake: key = Sec-WebSocket-Accept
[WS] WebsocketsClient::generateHandshake: value = BACScCJPNqyz+UBoqMH89VmURoA=
[WS] WebsocketsClient::generateHandshake: key = Origin
[WS] WebsocketsClient::generateHandshake: value = https://github.com/khoih-prog/Websockets2_Generic
Connnection Opened
Connected!
Got Message: Hello to Server from ESP32_DEV
Got a Pong!