# Websocket close codes

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: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

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

The question should be specific, self-contained, and written in natural language.
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.
