Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions public/_redirects
Original file line number Diff line number Diff line change
Expand Up @@ -358,16 +358,17 @@
/support/dns/troubleshooting/why-was-my-domain-deleted-from-cloudflare/ /dns/zone-setups/troubleshooting/domain-deleted/ 301

/durable-objects/examples/durable-object-example/ /durable-objects/examples/durable-object-in-memory-state/ 301
/durable-objects/api/hibernatable-websockets-api/ /durable-objects/api/websockets/ 301
/durable-objects/api/hibernatable-websockets-api/ /durable-objects/best-practices/websockets/ 301
/durable-objects/api/alarms-in-durable-objects/ /durable-objects/api/alarms/ 301
/durable-objects/api/websockets/ /durable-objects/best-practices/websockets/ 301
/durable-objects/platform/data-location/ /durable-objects/reference/data-location/ 301
/durable-objects/platform/environments/ /durable-objects/reference/environments/ 301
/durable-objects/platform/graphql-analytics/ /durable-objects/observability/graphql-analytics/ 301
/durable-objects/platform/troubleshooting/ /durable-objects/observability/troubleshooting/ 301
/durable-objects/learning/ /durable-objects/reference/ 301
/durable-objects/learning/in-memory-state/ /durable-objects/reference/in-memory-state/ 301
/durable-objects/learning/durable-objects-migrations/ /durable-objects/reference/durable-objects-migrations/ 301
/durable-objects/learning/websockets/ /durable-objects/reference/websockets/ 301
/durable-objects/learning/websockets/ /durable-objects/best-practices/websockets/ 301
/durable-objects/examples/durable-object-location-example/ /durable-objects/examples/durable-object-in-memory-state/ 301
/durable-objects/how-to/ /durable-objects/best-practices/ 301
/durable-objects/how-to/access-durable-object-from-a-worker/ /durable-objects/best-practices/access-durable-objects-from-a-worker/ 301
Expand All @@ -377,6 +378,7 @@
/durable-objects/reference/error-handling/ /durable-objects/best-practices/error-handling/ 301
/durable-objects/reference/troubleshooting/ /durable-objects/observability/troubleshooting/ 301
/durable-objects/reference/graphql-analytics/ /durable-objects/observability/graphql-analytics/ 301
/durable-objects/reference/websockets/ /durable-objects/best-practices/websockets/ 301
/durable-objects/api/transactional-storage-api/ /durable-objects/api/storage-api/ 301
/durable-objects/platform/changelog/ /durable-objects/changelog/ 301
/durable-objects/glossary/ /durable-objects/reference/glossary/ 301
Expand Down
2 changes: 1 addition & 1 deletion src/content/changelogs/workers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ entries:
- Added the [`strict_compression_checks`](/workers/configuration/compatibility-flags/#strict-compression-error-checking) compatibility flag for additional [`DecompressionStream`](/workers/runtime-apis/web-standards/#compression-streams) error checking.
- publish_date: "2023-05-26"
description: |-
- A new [Hibernatable WebSockets API](/durable-objects/api/websockets/)
- A new [Hibernatable WebSockets API](/durable-objects/best-practices/websockets/)
(beta) has been added to [Durable Objects](/durable-objects/). The Hibernatable
WebSockets API allows a Durable Object that is not currently running an event
handler (for example, processing a WebSocket message or alarm) to be removed from
Expand Down
16 changes: 8 additions & 8 deletions src/content/docs/durable-objects/api/state.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ export class MyDurableObject extends DurableObject {

### `acceptWebSocket`

`acceptWebSocket` is part of the [WebSocket Hibernation API](/durable-objects/reference/websockets/#websocket-hibernation), which allows a Durable Object to be removed from memory to save costs while keeping its WebSockets connected.
`acceptWebSocket` is part of the [WebSocket Hibernation API](/durable-objects/best-practices/websockets/#websocket-hibernation-api), which allows a Durable Object to be removed from memory to save costs while keeping its WebSockets connected.

`acceptWebSocket` adds a WebSocket to the set of WebSockets attached to the Durable Object. Once called, any incoming messages will be delivered by calling the Durable Object's `webSocketMessage` handler, and `webSocketClose` will be invoked upon disconnect. After calling `acceptWebSocket`, the WebSocket is accepted and its `send` and `close` methods can be used.

The [WebSocket Hibernation API](/durable-objects/reference/websockets/#websocket-hibernation) takes the place of the standard [WebSockets API](/workers/runtime-apis/websockets/). Therefore, `ws.accept` must not have been called separately and `ws.addEventListener` method will not receive events as they will instead be delivered to the Durable Object.
The [WebSocket Hibernation API](/durable-objects/best-practices/websockets/#websocket-hibernation-api) takes the place of the standard [WebSockets API](/workers/runtime-apis/websockets/). Therefore, `ws.accept` must not have been called separately and `ws.addEventListener` method will not receive events as they will instead be delivered to the Durable Object.

The WebSocket Hibernation API permits a maximum of 32,768 WebSocket connections per Durable Object, but the CPU and memory usage of a given workload may further limit the practical number of simultaneous connections.

Expand All @@ -125,7 +125,7 @@ The WebSocket Hibernation API permits a maximum of 32,768 WebSocket connections

### `getWebSockets`

`getWebSockets` is part of the [WebSocket Hibernation API](/durable-objects/reference/websockets/#websocket-hibernation), which allows a Durable Object to be removed from memory to save costs while keeping its WebSockets connected.
`getWebSockets` is part of the [WebSocket Hibernation API](/durable-objects/best-practices/websockets/#websocket-hibernation-api), which allows a Durable Object to be removed from memory to save costs while keeping its WebSockets connected.

`getWebSockets` returns an `Array<WebSocket>` which is the set of WebSockets attached to the Durable Object. An optional tag argument can be used to filter the list according to tags supplied when calling [`DurableObjectState::acceptWebSocket`](/durable-objects/api/state/#acceptwebsocket).

Expand All @@ -145,7 +145,7 @@ Disconnected WebSockets are not returned by this method, but `getWebSockets` may

### `setWebSocketAutoResponse`

`setWebSocketAutoResponse` is part of the [WebSocket Hibernation API](/durable-objects/reference/websockets/#websocket-hibernation), which allows a Durable Object to be removed from memory to save costs while keeping its WebSockets connected.
`setWebSocketAutoResponse` is part of the [WebSocket Hibernation API](/durable-objects/best-practices/websockets/#websocket-hibernation-api), which allows a Durable Object to be removed from memory to save costs while keeping its WebSockets connected.

`setWebSocketAutoResponse` sets an automatic response, auto-response, for the request provided for all WebSockets attached to the Durable Object. If a request is received matching the provided request then the auto-response will be returned without waking WebSockets in hibernation and incurring billable duration charges.

Expand Down Expand Up @@ -179,7 +179,7 @@ Disconnected WebSockets are not returned by this method, but `getWebSockets` may

### `getWebSocketAutoResponseTimestamp`

`getWebSocketAutoResponseTimestamp` is part of the [WebSocket Hibernation API](/durable-objects/reference/websockets/#websocket-hibernation), which allows a Durable Object to be removed from memory to save costs while keeping its WebSockets connected.
`getWebSocketAutoResponseTimestamp` is part of the [WebSocket Hibernation API](/durable-objects/best-practices/websockets/#websocket-hibernation-api), which allows a Durable Object to be removed from memory to save costs while keeping its WebSockets connected.

`getWebSocketAutoResponseTimestamp` gets the most recent `Date` on which the given WebSocket sent an auto-response, or null if the given WebSocket never sent an auto-response.

Expand All @@ -193,7 +193,7 @@ Disconnected WebSockets are not returned by this method, but `getWebSockets` may

### `setHibernatableWebSocketEventTimeout`

`setHibernatableWebSocketEventTimeout` is part of the [WebSocket Hibernation API](/durable-objects/reference/websockets/#websocket-hibernation), which allows a Durable Object to be removed from memory to save costs while keeping its WebSockets connected.
`setHibernatableWebSocketEventTimeout` is part of the [WebSocket Hibernation API](/durable-objects/best-practices/websockets/#websocket-hibernation-api), which allows a Durable Object to be removed from memory to save costs while keeping its WebSockets connected.

`setHibernatableWebSocketEventTimeout` sets the maximum amount of time in milliseconds that a WebSocket event can run for.

Expand All @@ -209,7 +209,7 @@ If no parameter or a parameter of `0` is provided and a timeout has been previou

### `getHibernatableWebSocketEventTimeout`

`getHibernatableWebSocketEventTimeout` is part of the [WebSocket Hibernation API](/durable-objects/reference/websockets/#websocket-hibernation), which allows a Durable Object to be removed from memory to save costs while keeping its WebSockets connected.
`getHibernatableWebSocketEventTimeout` is part of the [WebSocket Hibernation API](/durable-objects/best-practices/websockets/#websocket-hibernation-api), which allows a Durable Object to be removed from memory to save costs while keeping its WebSockets connected.

`getHibernatableWebSocketEventTimeout` gets the currently set hibernatable WebSocket event timeout if one has been set via [`DurableObjectState::setHibernatableWebSocketEventTimeout`](/durable-objects/api/state/#sethibernatablewebsocketeventtimeout).

Expand All @@ -223,7 +223,7 @@ If no parameter or a parameter of `0` is provided and a timeout has been previou

### `getTags`

`getTags` is part of the [WebSocket Hibernation API](/durable-objects/reference/websockets/#websocket-hibernation), which allows a Durable Object to be removed from memory to save costs while keeping its WebSockets connected.
`getTags` is part of the [WebSocket Hibernation API](/durable-objects/best-practices/websockets/#websocket-hibernation-api), which allows a Durable Object to be removed from memory to save costs while keeping its WebSockets connected.

`getTags` returns tags associated with a given WebSocket. This method throws an exception if the WebSocket has not been associated with the Durable Object via [`DurableObjectState::acceptWebSocket`](/durable-objects/api/state/#acceptwebsocket).

Expand Down
Loading
Loading