ws_protocol.ezdoc 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. ::: The Websocket protocol
  2. This chapter explains what Websocket is and why it is
  3. a vital component of soft realtime Web applications.
  4. :: Description
  5. Websocket is an extension to HTTP that emulates plain TCP
  6. connections between the client, typically a Web browser,
  7. and the server. It uses the HTTP Upgrade mechanism to
  8. establish the connection.
  9. Websocket connections are asynchronous, unlike HTTP. This
  10. means that not only can the client send frames to the server
  11. at any time, but the server can also send frames to the client
  12. without the client initiating anything other than the
  13. Websocket connection itself. This allows the server to push
  14. data to the client directly.
  15. Websocket is an IETF standard. Cowboy supports the standard
  16. and all drafts that were previously implemented by browsers,
  17. excluding the initial flawed draft sometimes known as
  18. "version 0".
  19. :: Implementation
  20. Cowboy implements Websocket as a protocol upgrade. Once the
  21. upgrade is performed from the `init/2` callback, Cowboy
  22. switches to Websocket. Please consult the next chapter for
  23. more information on initiating and handling Websocket
  24. connections.
  25. The implementation of Websocket in Cowboy is validated using
  26. the Autobahn test suite, which is an extensive suite of tests
  27. covering all aspects of the protocol. Cowboy passes the
  28. suite with 100% success, including all optional tests.
  29. Cowboy's Websocket implementation also includes the
  30. x-webkit-deflate-frame compression draft which is being used
  31. by some browsers to reduce the size of data being transmitted.
  32. Cowboy will automatically use compression as long as the
  33. `compress` protocol option is set when starting the listener.