Comments (10)
Is this a warning only or error? Is there anything wrong with the connection itself?
What sketch are you running?
from arduinowebsockets.
I'm running this example sketch:
using namespace websockets;
WebsocketsClient client;
void setup() {
Serial.begin(115200);
// Connect to wifi
WiFi.begin(ssid, password);
// Wait some time to connect to wifi
for(int i = 0; i < 10 && WiFi.status() != WL_CONNECTED; i++) {
Serial.print(".");
delay(1000);
}
// Check if connected to wifi
if(WiFi.status() != WL_CONNECTED) {
Serial.println("No Wifi!, But lest keep going");
}
Serial.println("Connected to Wifi, Connecting to server.");
// try to connect to Websockets server
bool connected = client.connect("ws://192.168.14.114:1234");
if(connected) {
Serial.println("Connecetd!");
client.send("Hello Server");
} else {
Serial.println("Not Connected!");
}
// run callback when messages are received
client.onMessage([&](WebsocketsMessage message){
Serial.print("Got Message: ");
Serial.println(message.data());
});
}
void loop() {
// let the websockets client check for incoming messages
if(client.available()) {
client.poll();
}
delay(500);
}
with verbose debug logs, but I see nothing except:
[D][WiFiGeneric.cpp:337] _eventCallback(): Event: 0 - WIFI_READY
[D][WiFiGeneric.cpp:337] _eventCallback(): Event: 2 - STA_START
.[D][WiFiGeneric.cpp:337] _eventCallback(): Event: 4 - STA_CONNECTED
[D][WiFiGeneric.cpp:337] _eventCallback(): Event: 7 - STA_GOT_IP
[D][WiFiGeneric.cpp:381] _eventCallback(): STA IP: 192.168.14.25, MASK: 255.255.255.0, GW: 192.168.14.1
Connected to Wifi, Connecting to server.
Connecetd!
Got Message: hello
Are you connecting to a wss server?
Thanks for opening the issue,
Gil.
from arduinowebsockets.
No response, no issue 👍
from arduinowebsockets.
Hi,
Oddly enough I found this (closed) issue while looking up the same error.
I don't know if this is related, but since I use a non-default secure port number, I found I had to use the full connection string to connect via wss://
eg:
const char *websockets_connection_string = "wss://ws.mydomain.uk:444/";
...
while (!client.connect(websockets_connection_string)) {
delay(500);
Serial.print(".");
}
..etc.
And when I connect, I also see :
[E][WiFiClient.cpp:309] setOption(): fail on fd -1, errno: 9, "Bad file number"
I also tried adding : client.setFragmentsPolicy(FragmentsPolicy_Notify);
before connect.
I note that it doesn't appear to actually break anything, but something is clearly not being configured correctly, maybe?
from arduinowebsockets.
Great, I'll re-open.
You should not call connect
multiple times on the same object. You should reset the object or do something like:
while(true) {
WebsocketsClient temp;
if (temp.connect(....)) {
client = temp;
break;
}
}
Or do anything else such that connect
will only be called once per client.
If you can adjust your code and manage to reproduce, I'll also try to re-produce this myself.
Gil.
from arduinowebsockets.
Sorry for no reply for so long time. I have problems with unreliable websocket connections (timeouts from time to time). But I don't think its related to this warning.
I'm also not using the wss default port. I connect to Port 444 with a self signed certificate and the appropriate SHA Hash.
from arduinowebsockets.
Hi,
I have adjusted my code to use a temporary object for connection similar to your example. (I also had to set my certificate and callbacks on the temp client object before connecting.)
But I am still seeing the same error.
[E][WiFiClient.cpp:309] setOption(): fail on fd -1, errno: 9, "Bad file number"
(I am also using port 444 on a LetsEncrypt certificate on my remote websocket server running a NodeJS script. Web-based clients have no problems or errors connecting via JS)
from arduinowebsockets.
Hi @friedemannm , is it possible that you get timeouts after long durations of inactivity? I know many server implementations are disconnecting clients after some time of inactivity, one way to solve this is by pinging the server (client.ping
).
Regarding the warning, it seems like it is caused because I'm calling setNoDelay
on the WiFiClients created by the library. The code used for standard clients and secured clients is the same (a template), but it seems like for SecureWiFiClient that option is not supported.
It seems like this warning has no negative effect other than the annoying message, I don't think this is worth the cost of "fixing".
Gil.
from arduinowebsockets.
I'm also getting this issue when trying to connect to the websocket.org's echo server (wss://echo.websocket.org)
EDIT to add more info:
Using an ESP32 based "Heltec Wifi Kit 32"
Code is copied straight from example, with the following change:
const char* websockets_server = "wss://echo.websocket.org"; //server address and port
from arduinowebsockets.
Its giving this error as it cannot reference this function from the original class.
from arduinowebsockets.
Related Issues (20)
- Hieromon/AutoConnect & WebSockets Client on ESP8266 - Can't Establish wss
- Secured-ESP8266-Client can't seem to receive any messages while connection is open HOT 1
- Compilation error: 'WebsocketsClient' does not name a type ?? HOT 3
- Getting a error from the TCPServer using the Arduino GIGA R1 WIFI on the ESP-32Client code. HOT 10
- ESP32-CAM WebSocket Server: Failure to Stream Camera Feed after Page Refresh or Multiple Connections
- WSS Connection error
- [ 5236][E][WiFiClient.cpp:313] setSocketOption(): fail on -1, errno: 9, "Bad file number" HOT 2
- Reconnecting after lost connection HOT 2
- Disconnecting almost inmediately
- Random disconnects, fails on binary ping including 0x00 HOT 1
- Issue with WSS and ESP 32 HOT 4
- Esp32 WebSocket Client won't work with WebSocket Node.js server. HOT 3
- Client-Message-Buffer
- ESP32 Server disconnected when receiving messages HOT 1
- Compilation errors with arduino_esp32 version 3.0.0 HOT 6
- wrong username
- Project is dead
- network::TcpServer* _server HOT 1
- Getting my connection closed when on node js wss server HOT 4
- Esp8266-Client example compiles with warnings, maybe others do too. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arduinowebsockets.