Git Product home page Git Product logo

Comments (11)

gilmaimon avatar gilmaimon commented on May 24, 2024 2

Hi @elC0mpa,

I think the issue is fixed now. It seems like Asyncwebserver expects the whole websockets frame to come as one chunck, and I separate it for convince. This is not a "client bug" per se, but because changing it won't harm the correctness of the impl and will only increase compatibility with other versions and implementations of websockets - I'm happy to make it.

The changes are in master, can you clone the repo (or pull the changes) and see if the issue is fixed for you as well?

Gil.

from arduinowebsockets.

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

As far as I tested, the library does handle the ping/pong situation. It does reply automatically with a pong every time receives a ping from the remote socket.

The server implementation you are using should reply with a pong to every ping request that is received from the micro-controller as well, if one is sent.

There's nothing that can be done on the library side, as it works accordingly.
See the RFCs here for details about how ping/pong frame is handled.
Perhaps you just have to configure your websocket server accordingly.

from arduinowebsockets.

gilmaimon avatar gilmaimon commented on May 24, 2024 1

@adelin-mcbsoft is absolutely right, the library will response with a pong every time a ping is received. The pong content will be the same as the content passed in the ping, as the RFC specifies.

Thanks for helping @adelin-mcbsoft.

The server I am using is from the Asyncwebserver library

Cool, I'll look into it tomorrow. Hopefully I will understand what is the issue (either in my or their impl). If I won't be able to reproduce using a Asyncwebserver server, I will let you know so we can continue to try and find the issue.

from arduinowebsockets.

gilmaimon avatar gilmaimon commented on May 24, 2024 1

Great, I'm happy to help. I'll wait for your updates.

Actually not only pongs crash, any kind of message sent to the server used to crash it. So the change was essentially to how the library sends any kind of websockets message.

Gil.

from arduinowebsockets.

gilmaimon avatar gilmaimon commented on May 24, 2024 1

Great, I'll release it as a patch right now.

I agree, it is a great change and I'm glad you surfaced this issue.

Thanks,
Gil.

from arduinowebsockets.

gilmaimon avatar gilmaimon commented on May 24, 2024

Steps to reproduce the behavior.

I'm sorry but there isn't enough info for me to reproduce or solve anything here. As you can guess pings should and are working fine for most people who use the library.

What is the server you are using? (software)
ESP debug logs can also be super useful.

from arduinowebsockets.

elC0mpa avatar elC0mpa commented on May 24, 2024

Ok @gilmaimon, I understand you. Later i will post the code. The server I am using is from the Asyncwebserver library. I just want to know something, isn't supposed that each time the websocket receives a ping, it should respond with a pong? In that case, how can i do it, I mean, a pong. Have you think about sending the pong automatically?

from arduinowebsockets.

elC0mpa avatar elC0mpa commented on May 24, 2024

You both are entirely right @gilmaimon and @adelin-mcbsoft, the library sends automatically a pong when it receives a ping. But there is a problem, when server receives the pong from the websocketclient wich is written using this library, it crashes. In order to detect the problem i programmed to log everything that is happening through serial. The problem is that, after receiving the pong answer from the client, it receives a binary message : 6e. In order to detect if the problem is related to the server, I did the same but using this library https://github.com/Links2004/arduinoWebSockets. The thing is that in this case, the server doesn't crash. So there should be a difference between your pong implementation and theirs. I hope this could Help you improving your library if i am right, I would like to keep using your library. Thanks in advance

from arduinowebsockets.

gilmaimon avatar gilmaimon commented on May 24, 2024

I understand everything works well? @elC0mpa

from arduinowebsockets.

elC0mpa avatar elC0mpa commented on May 24, 2024

Thanks for your answer @gilmaimon, I really appreciate your Help by changing the pong functionality of this library, I am busy right now but later i will clone the master branch and i will tell you if everything works as expected.

from arduinowebsockets.

elC0mpa avatar elC0mpa commented on May 24, 2024

It worked as expected @gilmaimon, now the websocketclient doesn't disconnect from server because the server doesn't crash. Thanks for your support, I really appreciate it, and i think this issue has helped to improve the compatibility of the library, so it has been good for you too. Thanks again

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.