GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Document Netty WebSocket compression · playframework/playframework@0b5c7a5

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • documentation/manual
    • releases/release31
      • Highlights31.md
    • working
      • javaGuide/main/async
        • JavaWebSockets.md
      • scalaGuide/main/async
        • ScalaWebSockets.md
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎documentation/manual/releases/release31/Highlights31.md‎

Copy file name to clipboardExpand all lines: documentation/manual/releases/release31/Highlights31.md
+14Lines changed: 14 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,20 @@ This section highlights the new features of Play 3.1. If you want to learn about
66

77
## Other Additions
88

9+
### Netty WebSocket Compression
10+
11+
The Play Netty server backend now supports WebSocket compression using the RFC 7692 `permessage-deflate` extension.
12+
13+
Compression is enabled by default and is negotiated during the WebSocket handshake when the client offers `permessage-deflate` in the `Sec-WebSocket-Extensions` header. Applications can disable WebSocket compression for all server backends with:
14+
15+
```hocon
16+
play.server.websocket.compression.enabled = false
17+
```
18+
19+
The Netty backend also exposes Netty-specific tuning options under `play.server.netty.websocket.compression`, including the compression level, negotiated window-size behavior, context-takeover behavior, and the decompression allocation limit. By default, the allocation limit follows `play.server.websocket.frame.maxLength`.
20+
21+
For more details, see the [[Scala WebSocket documentation|ScalaWebSockets#Configuring-WebSocket-compression]] and [[Java WebSocket documentation|JavaWebSockets#Configuring-WebSocket-compression]].
22+
923
### WebSocket Subprotocol Selection
1024

1125
Play now lets applications explicitly select the WebSocket subprotocol that is sent back in the successful `101 Switching Protocols` response.
Collapse file

‎documentation/manual/working/javaGuide/main/async/JavaWebSockets.md‎

Copy file name to clipboardExpand all lines: documentation/manual/working/javaGuide/main/async/JavaWebSockets.md
+14Lines changed: 14 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,20 @@ This configuration gives you more control of WebSocket frame length and can be a
120120

121121
The configuration above applies to WebSocket data frames. WebSocket Close frames, on the other hand, are control frames and have a smaller payload limit defined by [RFC 6455 section 5.5](https://www.rfc-editor.org/rfc/rfc6455#section-5.5). If a Close frame includes a status code, the status code uses 2 bytes, leaving at most 123 UTF-8 bytes for the close reason. Play truncates longer close reasons before sending them. Status codes `1005`, `1006`, and `1015` are reserved by [RFC 6455 section 7.4.1](https://www.rfc-editor.org/rfc/rfc6455#section-7.4.1) and should not be sent by application code as WebSocket Close frame status codes.
122122

123+
## Configuring WebSocket compression
124+
125+
The Netty server backend supports WebSocket compression using the RFC 7692 `permessage-deflate` extension. Compression is enabled by default and is negotiated during the WebSocket handshake when the client offers `permessage-deflate` in the `Sec-WebSocket-Extensions` header.
126+
127+
You can disable WebSocket compression for all server backends with:
128+
129+
```
130+
play.server.websocket.compression.enabled = false
131+
```
132+
133+
When using the Netty backend, Netty-specific compression settings are available under `play.server.netty.websocket.compression`. These settings include the compression level, negotiated window-size behavior, context-takeover behavior, and the maximum decompression allocation. By default, `play.server.netty.websocket.compression.maxAllocation` uses `play.server.websocket.frame.maxLength`, so the same limit applies to decompressed WebSocket messages.
134+
135+
> **Note:** WebSocket compression can increase CPU and memory usage. If messages include secrets alongside attacker-controlled data, consider whether compression is appropriate for that endpoint. Under the `play.server.netty.websocket` config parent, Netty's default context-takeover settings are `compression.perMessageDeflate.allowServerNoContext = false` and `compression.perMessageDeflate.preferredClientNoContext = false`. For a more conservative setup, set them to `true` so the server may accept `server_no_context_takeover` when the client requests it, and so Netty requests `client_no_context_takeover` when the client supports it.
136+
123137
## Configuring keep-alive Frames
124138

125139
First of all, if a client sends a `ping` Frame to the Play backend server, it automatically answers with a `pong` frame. This is a requirement according to [RFC 6455 Section 5.5.2](https://www.rfc-editor.org/rfc/rfc6455#section-5.5.2), therefore this is hardcoded within Play, you don't need to set up or configure anything.
Collapse file

‎documentation/manual/working/scalaGuide/main/async/ScalaWebSockets.md‎

Copy file name to clipboardExpand all lines: documentation/manual/working/scalaGuide/main/async/ScalaWebSockets.md
+14Lines changed: 14 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,20 @@ This configuration gives you more control of WebSocket frame length and can be a
122122

123123
The configuration above applies to WebSocket data frames. WebSocket Close frames, on the other hand, are control frames and have a smaller payload limit defined by [RFC 6455 section 5.5](https://www.rfc-editor.org/rfc/rfc6455#section-5.5). If a Close frame includes a status code, the status code uses 2 bytes, leaving at most 123 UTF-8 bytes for the close reason. Play truncates longer close reasons before sending them. Status codes `1005`, `1006`, and `1015` are reserved by [RFC 6455 section 7.4.1](https://www.rfc-editor.org/rfc/rfc6455#section-7.4.1) and should not be sent by application code as WebSocket Close frame status codes.
124124

125+
## Configuring WebSocket compression
126+
127+
The Netty server backend supports WebSocket compression using the RFC 7692 `permessage-deflate` extension. Compression is enabled by default and is negotiated during the WebSocket handshake when the client offers `permessage-deflate` in the `Sec-WebSocket-Extensions` header.
128+
129+
You can disable WebSocket compression for all server backends with:
130+
131+
```
132+
play.server.websocket.compression.enabled = false
133+
```
134+
135+
When using the Netty backend, Netty-specific compression settings are available under `play.server.netty.websocket.compression`. These settings include the compression level, negotiated window-size behavior, context-takeover behavior, and the maximum decompression allocation. By default, `play.server.netty.websocket.compression.maxAllocation` uses `play.server.websocket.frame.maxLength`, so the same limit applies to decompressed WebSocket messages.
136+
137+
> **Note:** WebSocket compression can increase CPU and memory usage. If messages include secrets alongside attacker-controlled data, consider whether compression is appropriate for that endpoint. Under the `play.server.netty.websocket` config parent, Netty's default context-takeover settings are `compression.perMessageDeflate.allowServerNoContext = false` and `compression.perMessageDeflate.preferredClientNoContext = false`. For a more conservative setup, set them to `true` so the server may accept `server_no_context_takeover` when the client requests it, and so Netty requests `client_no_context_takeover` when the client supports it.
138+
125139
## Configuring keep-alive Frames
126140

127141
First of all, if a client sends a `ping` Frame to the Play backend server, it automatically answers with a `pong` frame. This is a requirement according to [RFC 6455 Section 5.5.2](https://www.rfc-editor.org/rfc/rfc6455#section-5.5.2), therefore this is hardcoded within Play, you don't need to set up or configure anything.

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.