> For the complete documentation index, see [llms.txt](https://docs.arcware.cloud/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.arcware.cloud/web-integration/new-websdk/in-depth/events-handlers/websocket-close-codes.md).

# Websocket close codes

How to handle "Ticket destroyed" type of events?

To keep a session between Arcware and the client browser alive, there is an established websocket connection. The websocket transport can close for various reasons, which can be intentional or unintential. Also Arcware has reasons to forcefully close the connection from server side. In case you need to catch websocket closure, e.g. to re-establish connection or to track the event for reporting or monitoring, here you will find the codes that will be provided:

```typescript
// Assuming you have your PixelStreaming of ArcwareInit available
PixelStreaming.websocketOnCloseHandler.add((event: CloseEvent) => {
    console.log(`WebSocket closed. CloseCode: ${event.code} Reason: ${event.reason}`);
});
```

The WebSocket default close codes can be found [here](https://github.com/Luka967/websocket-close-codes).

Below you'll find a list of close codes custom to Arcware:

```typescript
export enum CloseCode {
  UNAUTHORIZED = 4450,
  UNAUTHORIZED_NO_BYPASS_REGISTERED = 4451,
  /** Unauthorized DirectFlow attempt. */
  UNAUTHORIZED_DF = 4452,

  SUSPENDED = 4453,

  TRIAL_LIMIT = 4460,
  MAX_RUNTIME = 4461,

  SESSION_NOT_FOUND = 4470,
  UNKNOWN_PROJECT = 4471,
  PROJECT_DISABLED = 4472,
  STREAM_DELETED = 4473,

  NO_STREAM_AVAILABLE = 4501,
  NO_PACKAGENAME_PROVIDED = 4502,
  STREAM_DISCONNECTED = 4503,
  STREAM_KEY_ALREADY_CONNECTED = 4504,
  CLIENT_OCCUPATION_LIMIT_REACHED = 4505,
  CLIENT_AFK = 4506,
  CLIENT_RECONNECTING = 4507,
  CLIENT_NO_PONG = 4508,
  CLIENT_DESTROYED = 4509,
  CLIENT_WITHOUT_TICKET = 4510,

  CLOSE_ABNORMAL_CUSTOM = 4606,
  CLOSE_SHARE_NO_RESOURCES_LEFT = 4607,
  CLOSE_SHARE_ERROR = 4608,

  CLOSE_INTERNAL_SERVER_ERROR = 4666
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.arcware.cloud/web-integration/new-websdk/in-depth/events-handlers/websocket-close-codes.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
