com.neovisionaries.ws.client.WebSocketError Maven / Gradle / Ivy
Show all versions of nv-websocket-client Show documentation
/*
* Copyright (C) 2015-2017 Neo Visionaries Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.neovisionaries.ws.client;
/**
* WebSocket error codes.
*
* @see WebSocketException#getError()
*/
public enum WebSocketError
{
/**
* The current state of the WebSocket is not CREATED.
*
*
* This error occurs if {@link WebSocket#connect()} is called
* when the state of the WebSocket is not {@link
* WebSocketState#CREATED CREATED}.
*
*/
NOT_IN_CREATED_STATE,
/**
* Failed to get the input stream of the raw socket.
*/
SOCKET_INPUT_STREAM_FAILURE,
/**
* Failed to get the output stream of the raw socket.
*/
SOCKET_OUTPUT_STREAM_FAILURE,
/**
* Failed to send an opening handshake request to the server.
*/
OPENING_HAHDSHAKE_REQUEST_FAILURE,
/**
* Failed to read an opening handshake response from the server.
*/
OPENING_HANDSHAKE_RESPONSE_FAILURE,
/**
* The status line of the opening handshake response is empty.
*/
STATUS_LINE_EMPTY,
/**
* The status line of the opening handshake response is badly formatted.
*/
STATUS_LINE_BAD_FORMAT,
/**
* The status code of the opening handshake response is not {@code 101 Switching Protocols}.
*/
NOT_SWITCHING_PROTOCOLS,
/**
* An error occurred while HTTP header section was being read.
*/
HTTP_HEADER_FAILURE,
/**
* The opening handshake response does not contain {@code Upgrade} header.
*/
NO_UPGRADE_HEADER,
/**
* {@code websocket} was not found in {@code Upgrade} header.
*/
NO_WEBSOCKET_IN_UPGRADE_HEADER,
/**
* The opening handshake response does not contain {@code Connection} header.
*/
NO_CONNECTION_HEADER,
/**
* {@code Upgrade} was not found in {@code Connection} header.
*/
NO_UPGRADE_IN_CONNECTION_HEADER,
/**
* The opening handshake response does not contain {@code Sec-WebSocket-Accept} header.
*/
NO_SEC_WEBSOCKET_ACCEPT_HEADER,
/**
* The value of {@code Sec-WebSocket-Accept} header is different from the expected one.
*/
UNEXPECTED_SEC_WEBSOCKET_ACCEPT_HEADER,
/**
* The value in {@code Sec-WebSocket-Extensions} failed to be parsed.
*/
EXTENSION_PARSE_ERROR,
/**
* The extension contained in {@code Sec-WebSocket-Extensions} header is not supported.
*/
UNSUPPORTED_EXTENSION,
/**
* The combination of the extensions contained in {@code Sec-WebSocket-Extensions} header
* causes conflicts.
*
* @since 1.15
*/
EXTENSIONS_CONFLICT,
/**
* The protocol contained in {@code Sec-WebSocket-Protocol} header is not supported.
*/
UNSUPPORTED_PROTOCOL,
/**
* The end of the stream has been reached unexpectedly.
*/
INSUFFICENT_DATA,
/**
* The payload length of a frame is invalid.
*/
INVALID_PAYLOAD_LENGTH,
/**
* The payload length of a frame exceeds the maximum array size in Java.
*/
TOO_LONG_PAYLOAD,
/**
* {@link OutOfMemoryError} occurred during a trial to allocate a memory area for a frame's payload.
*/
INSUFFICIENT_MEMORY_FOR_PAYLOAD,
/**
* Interruption occurred while a frame was being read from the WebSocket.
*/
INTERRUPTED_IN_READING,
/**
* An I/O error occurred while a frame was being read from the WebSocket.
*/
IO_ERROR_IN_READING,
/**
* An I/O error occurred when a frame was tried to be sent.
*/
IO_ERROR_IN_WRITING,
/**
* Flushing frames to the server failed.
*/
FLUSH_ERROR,
/**
* At least one of the reserved bits of a frame is set.
*
*
* From RFC 6455, 5.2 Base Framing Protocol; RSV1, RSV2, RSV3:
*
* MUST be 0 unless an extension is negotiated that defines meanings
* for non-zero values. If a nonzero value is received and none of
* the negotiated extensions defines the meaning of such a nonzero
* value, the receiving endpoint MUST Fail the WebSocket Connection.
*
*
*
*
* By calling {@link WebSocket#setExtended(boolean) WebSocket.setExtended}{@code
* (true)}, you can skip the validity check of the RSV1/RSV2/RSV3 bits.
*
*
*
* This error code is not used in version 1.15 and after.
*
*/
NON_ZERO_RESERVED_BITS,
/**
* A reserved bit of a frame has an unexpected value.
*
*
* From RFC 6455, 5.2 Base Framing Protocol; RSV1, RSV2, RSV3:
*
* MUST be 0 unless an extension is negotiated that defines meanings
* for non-zero values. If a nonzero value is received and none of
* the negotiated extensions defines the meaning of such a nonzero
* value, the receiving endpoint MUST Fail the WebSocket Connection.
*
*
*
*
* By calling {@link WebSocket#setExtended(boolean) WebSocket.setExtended}{@code
* (true)}, you can skip the validity check of the RSV1/RSV2/RSV3 bits.
*
*
* @since 1.15
*/
UNEXPECTED_RESERVED_BIT,
/**
* A frame from the server is masked.
*
*
* From RFC 6455, 5.1. Overview:
*
* A server MUST NOT mask any frames that it sends to the client.
* A client MUST close a connection if it detects a masked frame.
*
*
*/
FRAME_MASKED,
/**
* A frame has an unknown opcode.
*
*
* By calling {@link WebSocket#setExtended(boolean) WebSocket.setExtended}{@code
* (true)}, you can accept frames which have an unknown opcode.
*
*/
UNKNOWN_OPCODE,
/**
* A control frame is fragmented.
*
*
* From RFC 6455, 5.4. Fragmentation:
*
* Control frames (see Section 5.5) MAY be injected in the middle of
* a fragmented message. Control frames themselves MUST NOT be fragmented.
*
*
*/
FRAGMENTED_CONTROL_FRAME,
/**
* A continuation frame was detected although a continuation had not started.
*/
UNEXPECTED_CONTINUATION_FRAME,
/**
* A non-control frame was detected although the existing continuation had not been closed.
*/
CONTINUATION_NOT_CLOSED,
/**
* The payload size of a control frame exceeds the maximum size (125 bytes).
*
*
* From RFC 6455, 5.5. Control Frames:
*
* All control frames MUST have a payload length of 125 bytes or less and
* MUST NOT be fragmented.
*
*
*/
TOO_LONG_CONTROL_FRAME_PAYLOAD,
/**
* Failed to concatenate payloads of multiple frames to construct a message.
*/
MESSAGE_CONSTRUCTION_ERROR,
/**
* Failed to convert payload data into a string.
*/
TEXT_MESSAGE_CONSTRUCTION_ERROR,
/**
* An uncaught throwable was detected in the reading thread (which reads
* frames from the server).
*/
UNEXPECTED_ERROR_IN_READING_THREAD,
/**
* An uncaught throwable was detected in the writing thread (which sends
* frames to the server).
*/
UNEXPECTED_ERROR_IN_WRITING_THREAD,
/**
* {@code permessage-deflate} extension contains an unsupported parameter.
*
*
* See 7. The
* "permessage-deflate" Extension in
* RFC 7692 for details.
*
*
* @since 1.15
*/
PERMESSAGE_DEFLATE_UNSUPPORTED_PARAMETER,
/**
* The value of {@code server_max_window_bits} parameter or {@code
* client_max_window_bits} parameter of {@code permessage-deflate}
* extension is invalid.
*
*
* See 7.1.2.
* Limiting the LZ77 Sliding Window Size in
* RFC 7692 for details.
*
*
* @since 1.15
*/
PERMESSAGE_DEFLATE_INVALID_MAX_WINDOW_BITS,
/**
* Compression failed.
*
* @since 1.17
*/
COMPRESSION_ERROR,
/**
* Decompression failed.
*
* @since 1.16
*/
DECOMPRESSION_ERROR,
/**
* {@link java.net.Socket#connect(java.net.SocketAddress, int)
* Socket.connect()} failed.
*
* @since 1.20
*/
SOCKET_CONNECT_ERROR,
/**
* Handshake with a proxy server failed.
*
* @since 1.20
*/
PROXY_HANDSHAKE_ERROR,
/**
* Failed to overlay an existing socket.
*
* @since 1.20
*/
SOCKET_OVERLAY_ERROR,
/**
* SSL handshake with a WebSocket endpoint failed.
*
* @since 1.20
*/
SSL_HANDSHAKE_ERROR,
/**
* No more frame can be read because the end of the input stream has been reached.
*
*
* This happens when the WebSocket connection is closed without receiving a
* close frame
* from the WebSocket server. Strictly speaking, it is a violation against
* RFC 6455, but it seems some
* server implementations sometimes close a connection without sending a close
* frame.
*
*
* @since 1.29
*/
NO_MORE_FRAME,
/**
* The certificate of the peer does not match the expected hostname.
*
*
* When {@link WebSocketException#getError()} returns this error code, the
* {@link WebSocketException} can be cast to {@link HostnameUnverifiedException}
* through which you can get the
*
*
*
* See Verify that certificate is valid for server hostname (#107).
*
*
* @since 2.1
*/
HOSTNAME_UNVERIFIED,
;
}