Giter VIP home page Giter VIP logo

Comments (4)

lpinca avatar lpinca commented on May 29, 2024

I've tried adding on('error') listeners, and I can successfully "catch" the Error on the server side, but it seems like the library automatically closes the connection when this occurs? Is this the intended behaviour or am I likely not holding it correctly?

Yes, it is. The connection is closed with the 1009 status code when this happens. See https://www.rfc-editor.org/rfc/rfc6455.html#section-7.4.1.

from ws.

tomtomau avatar tomtomau commented on May 29, 2024

Ok, thanks for clarify that I'm at least not holding it incorrectly!

I'm not familiar with the rest of the specs, do they prescribe that a server must close the connection with 1009? Or just that if the server closes the connection due to exceeding the maximum payload size then it should use the 1009 code, and the only valid condition for returning 1009 code is due to exceeding the maximum payload size (i.e. don't use it for other reasons)

It seems unnecessary to have the server close the connection when it receives a message that is too large, when being able to handle it internally on the server as an "error" (in my case, sending back a message to the client to tell them it was too large) but continue to keep the connection open for more messages, but I'm not sure if that's just a fundamental misunderstanding of mine of the websocket protocol

from ws.

lpinca avatar lpinca commented on May 29, 2024

I think it is not mandatory but the behavior is common in the WebSocket implementations.

  1. It is a measure against a possibile DoS attack.
  2. If the connection is not closed, how do you handle these messages? Discarding them?
  3. The size is configurable.
  4. The endpoint is still informed of the problem via the close code.

from ws.

lpinca avatar lpinca commented on May 29, 2024

I'm closing this as answered.

from ws.

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.