Git Product home page Git Product logo

Comments (6)

adelin-mcbsoft avatar adelin-mcbsoft commented on May 24, 2024 2

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.

gilmaimon avatar gilmaimon commented on May 24, 2024 1

So, I consider this a potential feature rather than a bug. On my TODO list.

Gil.

from arduinowebsockets.

JohnInWI avatar JohnInWI commented on May 24, 2024 1

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.

gilmaimon avatar gilmaimon commented on May 24, 2024 1

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.

gilmaimon avatar gilmaimon commented on May 24, 2024

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.

gilmaimon avatar gilmaimon commented on May 24, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.