dxFeed Graal CXX API v9.0.0
Loading...
Searching...
No Matches
Connection troubleshooting

When an endpoint does not connect, or its connection drops, the endpoint tells why (an experimental API, it may change in future versions):

endpoint->addMessageConnectorListener([](const MessageConnectorInfo &connector) {
if (connector.lastError) {
std::cerr << connector.lastError->toString() << std::endl;
}
});
endpoint->connect("demo.dxfeed.com:7300");
A snapshot of a message connector of an endpoint: a connection to an address (DXEndpoint::getConnecto...
Definition MessageConnectorInfo.hpp:75
std::optional< ConnectionError > lastError
The last connection error of the connector, or std::nullopt when it has had none.
Definition MessageConnectorInfo.hpp:216

A successful connection clears no error: compare the time or the count of an error with those seen before. A state change listener of the endpoint is not the place to read the error: the state of the endpoint is computed on another thread, so the listener may be called before the error is recorded, and failed connect attempts do not change the state at all: the endpoint stays CONNECTING between them.

The categories and their usual causes:

Category Usual causes
DNS A mistake in the host name; no DNS server is reachable.
CONNECT_FAILED A wrong port; nothing listens on it; a firewall; the host is down or unreachable.
TLS A tls+ address of a port without TLS; a certificate that is not trusted.
CLOSED_BY_REMOTE The remote side closed the connection, for example on its restart.
HEARTBEAT_TIMEOUT The network or the remote side stalled: no data and no heartbeat came in time.
READ_TIMEOUT, IO Network problems, for example a connection reset.
OTHER Other errors, for example of the protocol or of the authentication: see the message.

DXEndpoint::connect() rejects a ws:// or wss:// URL and an http:// or https:// URL (except a configuration URL .../name.config#name) at once: such a URL is not an address of an endpoint. The Connect tool prints each new connection error to the standard error stream, one line per error. The errors of the library itself (the exceptions of the listeners and the like) go to ErrorManager: see Error handling.