Comments (6)
Hey,
I would like to have my opinion too here:
Just in case you consider adding keep-alive pings in the future, please make sure you add an optional flag for that (so you could set if you want them or not), as there are server/client implementations (see Web Browsers for example) which do not support ping / pong(s).
(Web Browsers in particular, act pretty ugly on them, they disconnect when they receive a ping/pong).
But anyway - may be a good idea to have them.
Regarding @JohnInWI's issue, I experience some sort of disconnects even after long-heavy-usage, but is still under investigation, the library might not be at fault, may be a HTTP SSL problem or so.
'til we find out - thank you once again Gil for the library! Best in town :D !
Have a great day,
A.
from arduinowebsockets.
So, I consider this a potential feature rather than a bug. On my TODO list.
Gil.
from arduinowebsockets.
Agreed- a feature rather than a bug. I can add a periodic ping to keep connection alive. The way it is, killing a non-active socket might be useful in some situations... although I cannot confirm it is the library doing the disconnect at this point.
Not sure how to get a detailed log from Node-Red's websockets... working on that... (no time!)
Again, thanks for the great library.
from arduinowebsockets.
So, I thought about this and my opinion is that a periodic ping is not something that should be implemented inside the client itself. It bounds the usage of the client to .poll
style of usage (instead of a readBlocking, if some users want it) and overall it is a responsibility I don't want the client to have (managing time, etc).
There are other solutions for doing work on fixed intervals, one of them is in my ArduinoComponents library (but if you are reading this you should probably find a better maintained library).
I'm closing the issue, but it is still open for discussion, I'm available via email [email protected]
Gil.
from arduinowebsockets.
Hi, thank you for opening an issue.
I'm not sure exactly if the server sends the disconnect or the server. If you could turn on logs (on highest verbosity) it could be very helpfull.
Anyway, the best way is to send some kind of "keepalive" message to the server, which is exactly why the websockets protocol has Ping packets.
Try adding code which sends a ping to the server every few minutes or so, it should fix your issue completely. (Just make sure you don't spam the server with pings without any delay).
I would still appreciate logs, and your issue makes me consider adding keep-alive pings as library feature. Let me know if it is something you are interested in :)
I'm on mobile so I apologise for not adding code samples. Let me know if you need any extra info or help!
Thanks again for using the library!
Have fun,
Gil.
from arduinowebsockets.
If you are using an ESP32, you can see the logging settings in the board menu. It's better to get the logs form the board itself rather than from the server.
For me, adding periodic pings fixed simmilar issue before (usually it is server configuration to avoid zombie connections).
Gil.
from arduinowebsockets.
Related Issues (20)
- ESP32-Server Not Working Properly receives one msg and gets disconnected HOT 3
- How to know hostname and IP from client? HOT 1
- esp32 to wss python server
- ESP32 Websocket Client doesn't connect to Node.js Websocket server HOT 3
- poll() disconnects client HOT 7
- How to get a reference of the web socket client that dispatched the msg callback
- 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 3
- 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
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.