dxFeed Graal CXX API v9.0.0
Loading...
Searching...
No Matches
ConnectionError Struct Reference

A connection error of a message connector of an endpoint: a failed connect attempt or a dropped connection (DXEndpoint::getLastConnectionError(), MessageConnectorInfo::lastError). More...

#include <ConnectionError.hpp>

Public Types

enum class  Category : std::int32_t {
  OTHER = 0 , DNS = 1 , CONNECT_FAILED = 2 , READ_TIMEOUT = 3 ,
  HEARTBEAT_TIMEOUT = 4 , CLOSED_BY_REMOTE = 5 , TLS = 6 , IO = 7
}
 The category of a connection error. More...

Public Member Functions

std::string toString () const
 Returns a string representation of the error in one line: the time, the category, whether the connection was dropped, the address, the exception, the message and the count.

Static Public Member Functions

static const char * categoryToString (Category category) noexcept
 Returns the name of a category, for example CONNECT_FAILED.

Public Attributes

std::int64_t time {}
 The time of the error, in milliseconds since the UNIX epoch (UTC).
std::string address {}
 The address the connector was configured with, credentials masked: for a multi-host address the whole list, not the host that failed.
Category category {Category::OTHER}
 The category of the error.
bool dropped {}
 true if an established connection was dropped, false if a connect attempt failed.
std::string exceptionClassName {}
 The class name of the Java exception, for example java.net.ConnectException, or an empty string when there is none.
std::string message {}
 The message of the exception (or of the log record when there is no exception), credentials masked, at most 256 characters; an empty string when there is none.
std::int64_t count {}
 The number of errors of the connector up to this one: it grows with each new error.

Detailed Description

A connection error of a message connector of an endpoint: a failed connect attempt or a dropped connection (DXEndpoint::getLastConnectionError(), MessageConnectorInfo::lastError).

The value is a copy: it does not change when the connector records a newer error. A successful connection clears nothing, the time tells how old the error is. See Connection troubleshooting.

This is an experimental API, it may change in future versions.

Member Enumeration Documentation

◆ Category

enum class ConnectionError::Category : std::int32_t
strong

The category of a connection error.

A category that this version of the library does not know reads as OTHER.

Enumerator
OTHER 0 

Another error, or a category that this version of the library does not know.

DNS 1 

The host name of the address is not resolved (Java: java.net.UnknownHostException).

CONNECT_FAILED 2 

The connect failed, was refused or timed out (Java: java.net.ConnectException, NoRouteToHostException, PortUnreachableException).

READ_TIMEOUT 3 

A read of an established connection timed out (Java: java.net.SocketTimeoutException).

HEARTBEAT_TIMEOUT 4 

The remote side sent no data and no heartbeat within the heartbeat timeout (the address option [heartbeatTimeout=...]), so the connection was closed; the error has no exception.

CLOSED_BY_REMOTE 5 

The remote side closed the connection (Java: java.io.EOFException).

TLS 6 

The TLS handshake or a TLS record failed, for example a tls+ address of a port without TLS or a certificate that is not trusted (Java: javax.net.ssl.SSLException).

IO 7 

Another I/O error, for example a connection reset (Java: java.io.IOException).

Member Function Documentation

◆ categoryToString()

const char * ConnectionError::categoryToString ( Category category)
staticnoexcept

Returns the name of a category, for example CONNECT_FAILED.

Parameters
categoryThe category.
Returns
The name of the category.

References CLOSED_BY_REMOTE, CONNECT_FAILED, DNS, HEARTBEAT_TIMEOUT, IO, OTHER, READ_TIMEOUT, and TLS.

◆ toString()

std::string ConnectionError::toString ( ) const

Returns a string representation of the error in one line: the time, the category, whether the connection was dropped, the address, the exception, the message and the count.

Returns
The string representation of the error.