(cobra client) send a websocket ping every 30s to keep the connection opened
This commit is contained in:
parent
b9cc6d7e23
commit
ee65f95fe3
@ -1,13 +1,16 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
All changes to this project will be documented in this file.
|
All changes to this project will be documented in this file.
|
||||||
|
|
||||||
|
## [7.6.5] - 2019-12-24
|
||||||
|
|
||||||
|
(cobra client) send a websocket ping every 30s to keep the connection opened
|
||||||
|
|
||||||
## [7.6.4] - 2019-12-22
|
## [7.6.4] - 2019-12-22
|
||||||
|
|
||||||
(client) error handling, quote url in error case when failing to parse one
|
(client) error handling, quote url in error case when failing to parse one
|
||||||
(ws) ws_cobra_publish: register callbacks before connecting
|
(ws) ws_cobra_publish: register callbacks before connecting
|
||||||
(doc) mention mbedtls in supported ssl server backend
|
(doc) mention mbedtls in supported ssl server backend
|
||||||
|
|
||||||
|
|
||||||
## [7.6.3] - 2019-12-20
|
## [7.6.3] - 2019-12-20
|
||||||
|
|
||||||
(tls) add a simple description of the TLS configuration routine for debugging
|
(tls) add a simple description of the TLS configuration routine for debugging
|
||||||
|
@ -24,6 +24,7 @@ namespace ix
|
|||||||
PublishTrackerCallback CobraConnection::_publishTrackerCallback = nullptr;
|
PublishTrackerCallback CobraConnection::_publishTrackerCallback = nullptr;
|
||||||
constexpr size_t CobraConnection::kQueueMaxSize;
|
constexpr size_t CobraConnection::kQueueMaxSize;
|
||||||
constexpr CobraConnection::MsgId CobraConnection::kInvalidMsgId;
|
constexpr CobraConnection::MsgId CobraConnection::kInvalidMsgId;
|
||||||
|
constexpr int CobraConnection::kPingIntervalSecs;
|
||||||
|
|
||||||
CobraConnection::CobraConnection() :
|
CobraConnection::CobraConnection() :
|
||||||
_webSocket(new WebSocket()),
|
_webSocket(new WebSocket()),
|
||||||
@ -228,6 +229,10 @@ namespace ix
|
|||||||
ss << "HTTP Status: " << msg->errorInfo.http_status << std::endl;
|
ss << "HTTP Status: " << msg->errorInfo.http_status << std::endl;
|
||||||
invokeErrorCallback(ss.str(), std::string());
|
invokeErrorCallback(ss.str(), std::string());
|
||||||
}
|
}
|
||||||
|
else if (msg->type == ix::WebSocketMessageType::Pong)
|
||||||
|
{
|
||||||
|
invokeEventCallback(ix::CobraConnection_EventType_Pong);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -260,6 +265,7 @@ namespace ix
|
|||||||
_webSocket->setUrl(url);
|
_webSocket->setUrl(url);
|
||||||
_webSocket->setPerMessageDeflateOptions(webSocketPerMessageDeflateOptions);
|
_webSocket->setPerMessageDeflateOptions(webSocketPerMessageDeflateOptions);
|
||||||
_webSocket->setTLSOptions(socketTLSOptions);
|
_webSocket->setTLSOptions(socketTLSOptions);
|
||||||
|
_webSocket->setPingInterval(kPingIntervalSecs);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -30,7 +30,8 @@ namespace ix
|
|||||||
CobraConnection_EventType_Closed = 3,
|
CobraConnection_EventType_Closed = 3,
|
||||||
CobraConnection_EventType_Subscribed = 4,
|
CobraConnection_EventType_Subscribed = 4,
|
||||||
CobraConnection_EventType_UnSubscribed = 5,
|
CobraConnection_EventType_UnSubscribed = 5,
|
||||||
CobraConnection_EventType_Published = 6
|
CobraConnection_EventType_Published = 6,
|
||||||
|
CobraConnection_EventType_Pong = 7
|
||||||
};
|
};
|
||||||
|
|
||||||
enum CobraConnectionPublishMode
|
enum CobraConnectionPublishMode
|
||||||
@ -215,6 +216,9 @@ namespace ix
|
|||||||
|
|
||||||
// Each pdu sent should have an incremental unique id
|
// Each pdu sent should have an incremental unique id
|
||||||
std::atomic<uint64_t> _id;
|
std::atomic<uint64_t> _id;
|
||||||
|
|
||||||
|
// Frequency at which we send a websocket ping to the backing cobra connection
|
||||||
|
static constexpr int kPingIntervalSecs = 30;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ix
|
} // namespace ix
|
||||||
|
@ -65,6 +65,10 @@ namespace ix
|
|||||||
{
|
{
|
||||||
ss << "Published message " << msgId << " acked";
|
ss << "Published message " << msgId << " acked";
|
||||||
}
|
}
|
||||||
|
else if (eventType == ix::CobraConnection_EventType_Pong)
|
||||||
|
{
|
||||||
|
ss << "Received websocket pong";
|
||||||
|
}
|
||||||
|
|
||||||
ix::IXCoreLogger::Log(ss.str().c_str());
|
ix::IXCoreLogger::Log(ss.str().c_str());
|
||||||
});
|
});
|
||||||
|
@ -6,4 +6,4 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define IX_WEBSOCKET_VERSION "7.6.4"
|
#define IX_WEBSOCKET_VERSION "7.6.5"
|
||||||
|
@ -91,6 +91,10 @@ namespace ix
|
|||||||
spdlog::info("Published message id {} acked", msgId);
|
spdlog::info("Published message id {} acked", msgId);
|
||||||
messageAcked = true;
|
messageAcked = true;
|
||||||
}
|
}
|
||||||
|
else if (eventType == ix::CobraConnection_EventType_Pong)
|
||||||
|
{
|
||||||
|
spdlog::info("Received websocket pong");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
conn.connect();
|
conn.connect();
|
||||||
|
@ -100,6 +100,10 @@ namespace ix
|
|||||||
{
|
{
|
||||||
spdlog::error("Published message hacked: {}", msgId);
|
spdlog::error("Published message hacked: {}", msgId);
|
||||||
}
|
}
|
||||||
|
else if (eventType == ix::CobraConnection_EventType_Pong)
|
||||||
|
{
|
||||||
|
spdlog::info("Received websocket pong");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
|
@ -245,6 +245,10 @@ namespace ix
|
|||||||
{
|
{
|
||||||
spdlog::error("Published message hacked: {}", msgId);
|
spdlog::error("Published message hacked: {}", msgId);
|
||||||
}
|
}
|
||||||
|
else if (eventType == ix::CobraConnection_EventType_Pong)
|
||||||
|
{
|
||||||
|
spdlog::info("Received websocket pong");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
|
@ -160,6 +160,10 @@ namespace ix
|
|||||||
{
|
{
|
||||||
spdlog::error("Published message hacked: {}", msgId);
|
spdlog::error("Published message hacked: {}", msgId);
|
||||||
}
|
}
|
||||||
|
else if (eventType == ix::CobraConnection_EventType_Pong)
|
||||||
|
{
|
||||||
|
spdlog::info("Received websocket pong");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
|
Loading…
Reference in New Issue
Block a user