123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- const error_1 = require("../utils/error");
- const error_config_1 = require("../config/error.config");
- exports.CLOSE_EVENT_CODE_INFO = {
- 1000: {
- code: 1000,
- name: 'Normal Closure',
- description: 'Normal closure; the connection successfully completed whatever purpose for which it was created.'
- },
- 1001: {
- code: 1001,
- name: 'Going Away',
- description: 'The endpoint is going away, either because of a server failure or because the browser is navigating away from the page that opened the connection.'
- },
- 1002: {
- code: 1002,
- name: 'Protocol Error',
- description: 'The endpoint is terminating the connection due to a protocol error.'
- },
- 1003: {
- code: 1003,
- name: 'Unsupported Data',
- description: 'The connection is being terminated because the endpoint received data of a type it cannot accept (for example, a text-only endpoint received binary data).'
- },
- 1005: {
- code: 1005,
- name: 'No Status Received',
- description: 'Indicates that no status code was provided even though one was expected.'
- },
- 1006: {
- code: 1006,
- name: 'Abnormal Closure',
- description: 'Used to indicate that a connection was closed abnormally (that is, with no close frame being sent) when a status code is expected.'
- },
- 1007: {
- code: 1007,
- name: 'Invalid frame payload data',
- description: 'The endpoint is terminating the connection because a message was received that contained inconsistent data (e.g., non-UTF-8 data within a text message).'
- },
- 1008: {
- code: 1008,
- name: 'Policy Violation',
- description: 'The endpoint is terminating the connection because it received a message that violates its policy. This is a generic status code, used when codes 1003 and 1009 are not suitable.'
- },
- 1009: {
- code: 1009,
- name: 'Message too big',
- description: 'The endpoint is terminating the connection because a data frame was received that is too large.'
- },
- 1010: {
- code: 1010,
- name: 'Missing Extension',
- description: "The client is terminating the connection because it expected the server to negotiate one or more extension, but the server didn't."
- },
- 1011: {
- code: 1011,
- name: 'Internal Error',
- description: 'The server is terminating the connection because it encountered an unexpected condition that prevented it from fulfilling the request.'
- },
- 1012: {
- code: 1012,
- name: 'Service Restart',
- description: 'The server is terminating the connection because it is restarting.'
- },
- 1013: {
- code: 1013,
- name: 'Try Again Later',
- description: 'The server is terminating the connection due to a temporary condition, e.g. it is overloaded and is casting off some of its clients.'
- },
- 1014: {
- code: 1014,
- name: 'Bad Gateway',
- description: 'The server was acting as a gateway or proxy and received an invalid response from the upstream server. This is similar to 502 HTTP Status Code.'
- },
- 1015: {
- code: 1015,
- name: 'TLS Handshake',
- description: "Indicates that the connection was closed due to a failure to perform a TLS handshake (e.g., the server certificate can't be verified)."
- },
- 3000: {
- code: 3000,
- name: 'Reconnect WebSocket',
- description: 'The client is terminating the connection because it wants to reconnect'
- },
- 3001: {
- code: 3001,
- name: 'No Realtime Listeners',
- description: 'The client is terminating the connection because no more realtime listeners exist'
- },
- 3002: {
- code: 3002,
- name: 'Heartbeat Ping Error',
- description: 'The client is terminating the connection due to its failure in sending heartbeat messages'
- },
- 3003: {
- code: 3003,
- name: 'Heartbeat Pong Timeout Error',
- description: 'The client is terminating the connection because no heartbeat response is received from the server'
- },
- 3050: {
- code: 3050,
- name: 'Server Close',
- description: 'The client is terminating the connection because no heartbeat response is received from the server'
- }
- };
- var CLOSE_EVENT_CODE;
- (function (CLOSE_EVENT_CODE) {
- CLOSE_EVENT_CODE[CLOSE_EVENT_CODE["NormalClosure"] = 1000] = "NormalClosure";
- CLOSE_EVENT_CODE[CLOSE_EVENT_CODE["GoingAway"] = 1001] = "GoingAway";
- CLOSE_EVENT_CODE[CLOSE_EVENT_CODE["ProtocolError"] = 1002] = "ProtocolError";
- CLOSE_EVENT_CODE[CLOSE_EVENT_CODE["UnsupportedData"] = 1003] = "UnsupportedData";
- CLOSE_EVENT_CODE[CLOSE_EVENT_CODE["NoStatusReceived"] = 1005] = "NoStatusReceived";
- CLOSE_EVENT_CODE[CLOSE_EVENT_CODE["AbnormalClosure"] = 1006] = "AbnormalClosure";
- CLOSE_EVENT_CODE[CLOSE_EVENT_CODE["InvalidFramePayloadData"] = 1007] = "InvalidFramePayloadData";
- CLOSE_EVENT_CODE[CLOSE_EVENT_CODE["PolicyViolation"] = 1008] = "PolicyViolation";
- CLOSE_EVENT_CODE[CLOSE_EVENT_CODE["MessageTooBig"] = 1009] = "MessageTooBig";
- CLOSE_EVENT_CODE[CLOSE_EVENT_CODE["MissingExtension"] = 1010] = "MissingExtension";
- CLOSE_EVENT_CODE[CLOSE_EVENT_CODE["InternalError"] = 1011] = "InternalError";
- CLOSE_EVENT_CODE[CLOSE_EVENT_CODE["ServiceRestart"] = 1012] = "ServiceRestart";
- CLOSE_EVENT_CODE[CLOSE_EVENT_CODE["TryAgainLater"] = 1013] = "TryAgainLater";
- CLOSE_EVENT_CODE[CLOSE_EVENT_CODE["BadGateway"] = 1014] = "BadGateway";
- CLOSE_EVENT_CODE[CLOSE_EVENT_CODE["TLSHandshake"] = 1015] = "TLSHandshake";
- CLOSE_EVENT_CODE[CLOSE_EVENT_CODE["ReconnectWebSocket"] = 3000] = "ReconnectWebSocket";
- CLOSE_EVENT_CODE[CLOSE_EVENT_CODE["NoRealtimeListeners"] = 3001] = "NoRealtimeListeners";
- CLOSE_EVENT_CODE[CLOSE_EVENT_CODE["HeartbeatPingError"] = 3002] = "HeartbeatPingError";
- CLOSE_EVENT_CODE[CLOSE_EVENT_CODE["HeartbeatPongTimeoutError"] = 3003] = "HeartbeatPongTimeoutError";
- CLOSE_EVENT_CODE[CLOSE_EVENT_CODE["NoAuthentication"] = 3050] = "NoAuthentication";
- })(CLOSE_EVENT_CODE = exports.CLOSE_EVENT_CODE || (exports.CLOSE_EVENT_CODE = {}));
- exports.getWSCloseError = (code, reason) => {
- const info = exports.CLOSE_EVENT_CODE_INFO[code];
- const errMsg = !info
- ? `code ${code}`
- : `${info.name}, code ${code}, reason ${reason || info.description}`;
- return new error_1.CloudSDKError({
- errCode: error_config_1.ERR_CODE.SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_CLOSED,
- errMsg
- });
- };
|