GithubHelp home page GithubHelp logo

Comments (6)

 avatar commented on August 15, 2024

Here's an example of how to do a WebSocket upgrade with Hyper.

https://github.com/krzysztofwos/hyper-websocket-upgrade

I am evaluating tokio-tungstenite for my next project. The problem that I am experiencing right now is that there seems to be no way to gracefully initiate the closing handshake from the server side with a custom close code and close reason (something that's possible with tungstenite), because when I get a sink and a stream I no longer have any interface to send a closing frame. Any ideas on how to address this?

from tokio-tungstenite.

daniel-abramov avatar daniel-abramov commented on August 15, 2024

Thanks for providing the example for others, unfortunately we did not have time to check the hyper implementation and prepare another example.

As for the closing of the websocket connection -- you're right and we also thought about that. I think that one of the possible solutions may be an addition of close message to the Message enum, currently the Message allows you to construct binary and text messages as well as Ping and Pong messages, but since Close message is kind of special, we did not add it do the enum yet. Perhaps it would make sense to add the possibility to send the Close message as Message::Close(Reason).

We actually discussed that once here: #45

But somehow did not get to the point where we had time to do the change (it should probably be rather a small change though).

from tokio-tungstenite.

 avatar commented on August 15, 2024

Yes, I think it would be a fine solution. This is what websocket crate does.

from tokio-tungstenite.

daniel-abramov avatar daniel-abramov commented on August 15, 2024

For the hyper example (original question) I think you can refer to the already mentioned: https://github.com/krzysztofwos/hyper-websocket-upgrade

Would it be sufficient?

As for the possibility to get close errors, it's now merged to master (see #53), so you can use it already. We'll may also release a new version of tungstenite-rs and tokio-tungstenite.

from tokio-tungstenite.

jbg avatar jbg commented on August 15, 2024

https://github.com/krzysztofwos/hyper-websocket-upgrade is a 404 error now, is there any newer example for hyper & tokio-tungstenite?

from tokio-tungstenite.

holly-hacker avatar holly-hacker commented on August 15, 2024

For those still looking for an alternative, hyper-tungstenite seems like a way to do this.

from tokio-tungstenite.

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.