(ws) ws connect gains a new option to set the interval at which to send pings

This commit is contained in:
Benjamin Sergeant 2020-03-17 23:54:32 -07:00
parent c6204f4d90
commit 8ec515f292
4 changed files with 50 additions and 6 deletions

View File

@ -1,6 +1,39 @@
# Changelog
All changes to this project will be documented in this file.
## [8.2.7] - 2020-03-17
(ws) ws connect gains a new option to set the interval at which to send pings
```
IXWebSocket$ ws connect --ping_interval 2 wss://echo.websocket.org
Type Ctrl-D to exit prompt...
Connecting to url: wss://echo.websocket.org
> ws_connect: connected
[2020-03-17 23:53:02.726] [info] Uri: /
[2020-03-17 23:53:02.726] [info] Headers:
[2020-03-17 23:53:02.727] [info] Connection: Upgrade
[2020-03-17 23:53:02.727] [info] Date: Wed, 18 Mar 2020 06:45:05 GMT
[2020-03-17 23:53:02.727] [info] Sec-WebSocket-Accept: 0gtqbxW0aVL/QI/ICpLFnRaiKgA=
[2020-03-17 23:53:02.727] [info] sec-websocket-extensions:
[2020-03-17 23:53:02.727] [info] Server: Kaazing Gateway
[2020-03-17 23:53:02.727] [info] Upgrade: websocket
[2020-03-17 23:53:04.894] [info] Received pong
[2020-03-17 23:53:06.859] [info] Received pong
[2020-03-17 23:53:08.881] [info] Received pong
[2020-03-17 23:53:10.848] [info] Received pong
[2020-03-17 23:53:12.898] [info] Received pong
[2020-03-17 23:53:14.865] [info] Received pong
[2020-03-17 23:53:16.890] [info] Received pong
[2020-03-17 23:53:18.853] [info] Received pong
[2020-03-17 23:53:19.388] [info]
ws_connect: connection closed: code 1000 reason Normal closure
[2020-03-17 23:53:19.502] [info] Received 208 bytes
[2020-03-17 23:53:19.502] [info] Sent 0 bytes
```
## [8.2.6] - 2020-03-16
(cobra to sentry bot + docker) default docker file uses mbedtls + ws cobra_to_sentry pass tls options to sentryClient.

View File

@ -112,6 +112,7 @@ int main(int argc, char** argv)
int count = 1;
uint32_t maxWaitBetweenReconnectionRetries;
size_t maxQueueSize = 100;
int pingIntervalSecs = 30;
auto addTLSOptions = [&tlsOptions, &verifyNone](CLI::App* app) {
app->add_option(
@ -170,6 +171,9 @@ int main(int argc, char** argv)
connectApp->add_option("--max_wait",
maxWaitBetweenReconnectionRetries,
"Max Wait Time between reconnection retries");
connectApp->add_option("--ping_interval",
pingIntervalSecs,
"Interval between sending pings");
connectApp->add_option("--subprotocol", subprotocol, "Subprotocol");
addTLSOptions(connectApp);
@ -389,7 +393,8 @@ int main(int argc, char** argv)
binaryMode,
maxWaitBetweenReconnectionRetries,
tlsOptions,
subprotocol);
subprotocol,
pingIntervalSecs);
}
else if (app.got_subcommand("chat"))
{

View File

@ -50,7 +50,8 @@ namespace ix
bool binaryMode,
uint32_t maxWaitBetweenReconnectionRetries,
const ix::SocketTLSOptions& tlsOptions,
const std::string& subprotocol);
const std::string& subprotocol,
int pingIntervalSecs);
int ws_receive_main(const std::string& url,
bool enablePerMessageDeflate,

View File

@ -24,7 +24,8 @@ namespace ix
bool binaryMode,
uint32_t maxWaitBetweenReconnectionRetries,
const ix::SocketTLSOptions& tlsOptions,
const std::string& subprotocol);
const std::string& subprotocol,
int pingIntervalSecs);
void subscribe(const std::string& channel);
void start();
@ -61,7 +62,8 @@ namespace ix
bool binaryMode,
uint32_t maxWaitBetweenReconnectionRetries,
const ix::SocketTLSOptions& tlsOptions,
const std::string& subprotocol)
const std::string& subprotocol,
int pingIntervalSecs)
: _url(url)
, _disablePerMessageDeflate(disablePerMessageDeflate)
, _binaryMode(binaryMode)
@ -74,6 +76,7 @@ namespace ix
}
_webSocket.setMaxWaitBetweenReconnectionRetries(maxWaitBetweenReconnectionRetries);
_webSocket.setTLSOptions(tlsOptions);
_webSocket.setPingInterval(pingIntervalSecs);
_headers = parseHeaders(headers);
@ -223,7 +226,8 @@ namespace ix
bool binaryMode,
uint32_t maxWaitBetweenReconnectionRetries,
const ix::SocketTLSOptions& tlsOptions,
const std::string& subprotocol)
const std::string& subprotocol,
int pingIntervalSecs)
{
std::cout << "Type Ctrl-D to exit prompt..." << std::endl;
WebSocketConnect webSocketChat(url,
@ -233,7 +237,8 @@ namespace ix
binaryMode,
maxWaitBetweenReconnectionRetries,
tlsOptions,
subprotocol);
subprotocol,
pingIntervalSecs);
webSocketChat.start();
while (true)