File tree 9 files changed +36
-3
lines changed
9 files changed +36
-3
lines changed Original file line number Diff line number Diff line change 1
1
# Changelog
2
2
All changes to this project will be documented in this file.
3
3
4
+ ## [ 7.6.5] - 2019-12-24
5
+
6
+ (cobra client) send a websocket ping every 30s to keep the connection opened
7
+
4
8
## [ 7.6.4] - 2019-12-22
5
9
6
10
(client) error handling, quote url in error case when failing to parse one
7
11
(ws) ws_cobra_publish: register callbacks before connecting
8
12
(doc) mention mbedtls in supported ssl server backend
9
13
10
-
11
14
## [ 7.6.3] - 2019-12-20
12
15
13
16
(tls) add a simple description of the TLS configuration routine for debugging
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ namespace ix
24
24
PublishTrackerCallback CobraConnection::_publishTrackerCallback = nullptr ;
25
25
constexpr size_t CobraConnection::kQueueMaxSize ;
26
26
constexpr CobraConnection::MsgId CobraConnection::kInvalidMsgId ;
27
+ constexpr int CobraConnection::kPingIntervalSecs ;
27
28
28
29
CobraConnection::CobraConnection () :
29
30
_webSocket (new WebSocket()),
@@ -228,6 +229,10 @@ namespace ix
228
229
ss << " HTTP Status: " << msg->errorInfo .http_status << std::endl;
229
230
invokeErrorCallback (ss.str (), std::string ());
230
231
}
232
+ else if (msg->type == ix::WebSocketMessageType::Pong)
233
+ {
234
+ invokeEventCallback (ix::CobraConnection_EventType_Pong);
235
+ }
231
236
});
232
237
}
233
238
@@ -260,6 +265,7 @@ namespace ix
260
265
_webSocket->setUrl (url);
261
266
_webSocket->setPerMessageDeflateOptions (webSocketPerMessageDeflateOptions);
262
267
_webSocket->setTLSOptions (socketTLSOptions);
268
+ _webSocket->setPingInterval (kPingIntervalSecs );
263
269
}
264
270
265
271
//
Original file line number Diff line number Diff line change @@ -30,7 +30,8 @@ namespace ix
30
30
CobraConnection_EventType_Closed = 3 ,
31
31
CobraConnection_EventType_Subscribed = 4 ,
32
32
CobraConnection_EventType_UnSubscribed = 5 ,
33
- CobraConnection_EventType_Published = 6
33
+ CobraConnection_EventType_Published = 6 ,
34
+ CobraConnection_EventType_Pong = 7
34
35
};
35
36
36
37
enum CobraConnectionPublishMode
@@ -215,6 +216,9 @@ namespace ix
215
216
216
217
// Each pdu sent should have an incremental unique id
217
218
std::atomic<uint64_t > _id;
219
+
220
+ // Frequency at which we send a websocket ping to the backing cobra connection
221
+ static constexpr int kPingIntervalSecs = 30 ;
218
222
};
219
223
220
224
} // namespace ix
Original file line number Diff line number Diff line change @@ -65,6 +65,10 @@ namespace ix
65
65
{
66
66
ss << " Published message " << msgId << " acked" ;
67
67
}
68
+ else if (eventType == ix::CobraConnection_EventType_Pong)
69
+ {
70
+ ss << " Received websocket pong" ;
71
+ }
68
72
69
73
ix::IXCoreLogger::Log (ss.str ().c_str ());
70
74
});
Original file line number Diff line number Diff line change 6
6
7
7
#pragma once
8
8
9
- #define IX_WEBSOCKET_VERSION "7.6.4 "
9
+ #define IX_WEBSOCKET_VERSION "7.6.5 "
Original file line number Diff line number Diff line change @@ -91,6 +91,10 @@ namespace ix
91
91
spdlog::info (" Published message id {} acked" , msgId);
92
92
messageAcked = true ;
93
93
}
94
+ else if (eventType == ix::CobraConnection_EventType_Pong)
95
+ {
96
+ spdlog::info (" Received websocket pong" );
97
+ }
94
98
});
95
99
96
100
conn.connect ();
Original file line number Diff line number Diff line change @@ -100,6 +100,10 @@ namespace ix
100
100
{
101
101
spdlog::error (" Published message hacked: {}" , msgId);
102
102
}
103
+ else if (eventType == ix::CobraConnection_EventType_Pong)
104
+ {
105
+ spdlog::info (" Received websocket pong" );
106
+ }
103
107
});
104
108
105
109
while (true )
Original file line number Diff line number Diff line change @@ -245,6 +245,10 @@ namespace ix
245
245
{
246
246
spdlog::error (" Published message hacked: {}" , msgId);
247
247
}
248
+ else if (eventType == ix::CobraConnection_EventType_Pong)
249
+ {
250
+ spdlog::info (" Received websocket pong" );
251
+ }
248
252
});
249
253
250
254
while (true )
Original file line number Diff line number Diff line change @@ -160,6 +160,10 @@ namespace ix
160
160
{
161
161
spdlog::error (" Published message hacked: {}" , msgId);
162
162
}
163
+ else if (eventType == ix::CobraConnection_EventType_Pong)
164
+ {
165
+ spdlog::info (" Received websocket pong" );
166
+ }
163
167
});
164
168
165
169
while (true )
You can’t perform that action at this time.
0 commit comments