Changeset - 4c938e9f17b2
[Not reviewed]
0 1 0
Jan Kaluza - 10 years ago 2016-01-07 12:35:53
jkaluza@redhat.com
WebSocketClient: Handle DNS errors
1 file changed with 13 insertions and 1 deletions:
0 comments (0 inline, 0 general)
libtransport/WebSocketClient.cpp
Show inline comments
 
@@ -212,21 +212,33 @@ void WebSocketClient::handleConnected(bool error) {
 
	m_conn->write(Swift::createSafeByteArray(req));
 
}
 

	
 
void WebSocketClient::handleDisconnected(const boost::optional<Swift::Connection::Error> &error) {
 
	if (!error) {
 
		return;
 
	}
 

	
 
	LOG4CXX_ERROR(logger, "Disconected from " << m_host << ". Will reconnect in 1 second.");
 
	m_reconnectTimer->start();
 
}
 

	
 
void WebSocketClient::handleDNSResult(const std::vector<Swift::HostAddress> &addrs, boost::optional<Swift::DomainNameResolveError>) {
 
void WebSocketClient::handleDNSResult(const std::vector<Swift::HostAddress> &addrs, boost::optional<Swift::DomainNameResolveError> error) {
 
	if (error) {
 
		LOG4CXX_ERROR(logger, "DNS resolving error. Will try again in 1 second.");
 
		m_reconnectTimer->start();
 
		return;
 
	}
 

	
 
	if (addrs.empty()) {
 
		LOG4CXX_ERROR(logger, "DNS name cannot be resolved. Will try again in 1 second.");
 
		m_reconnectTimer->start();
 
		return;
 
	}
 

	
 
	m_conn = m_tlsConnectionFactory->createConnection();
 
	m_conn->onDataRead.connect(boost::bind(&WebSocketClient::handleDataRead, this, _1));
 
	m_conn->onConnectFinished.connect(boost::bind(&WebSocketClient::handleConnected, this, _1));
 
	m_conn->onDisconnected.connect(boost::bind(&WebSocketClient::handleDisconnected, this, _1));
 
	m_conn->connect(Swift::HostAddressPort(addrs[0], 443));
 
}
 

	
 
}
0 comments (0 inline, 0 general)