Coder Social home page Coder Social logo

Comments (5)

synodriver avatar synodriver commented on June 16, 2024 2

Hi. According to the spec, http.disconnect is an asgi receive event instead of send event, so you can not close the http connection in that way. Return 500 error would be ok.

from hypercorn.

touilleMan avatar touilleMan commented on June 16, 2024

@synodriver Ho you're right ! I read the spec a bit too fast ^^

It looks like an omission to me, especially given the websocket stream has code for handling it corresponding websocket.close

So websocket.disconnect is also an event send to the application, hence wasn't hypercorn supposed to have raise an hypercorn.utils.UnexpectedMessageError when my application sent a websocket.disconnect to the server ?

from hypercorn.

synodriver avatar synodriver commented on June 16, 2024

You can send websocket.close which is listed in asgi spec.

Close - send event
Sent by the application to tell the server to close the connection.

If this is sent before the socket is accepted, the server must close the connection with a HTTP 403 error code (Forbidden), and not complete the WebSocket handshake; this may present on some browsers as a different WebSocket error code (such as 1006, Abnormal Closure).

If this is sent after the socket is accepted, the server must close the socket with the close code passed in the message (or 1000 if none is specified).

type (Unicode string) – "websocket.close".
code (int) – The WebSocket close code, as per the WebSocket spec. Optional; if missing defaults to 1000.
reason (Unicode string) – A reason given for the closure, can be any string. Optional; if missing or None default is empty string.

from hypercorn.

synodriver avatar synodriver commented on June 16, 2024

So websocket.disconnect is also an event send to the application, hence wasn't hypercorn supposed to have raise an hypercorn.utils.UnexpectedMessageError when my application sent a websocket.disconnect to the server ?

Actually hypercorn did it here

from hypercorn.

touilleMan avatar touilleMan commented on June 16, 2024

thanks a lot @synodriver 😃 🎉

so it's websocket.close that is the event the application send, and websocket.disconnect (and http.disconnect) that are send to the application !

from hypercorn.

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.