File tree Expand file tree Collapse file tree 2 files changed +22
-15
lines changed
examples/hello-cpp-client
libs/server-sent-events/src Expand file tree Collapse file tree 2 files changed +22
-15
lines changed Original file line number Diff line number Diff line change @@ -62,19 +62,6 @@ int main() {
62
62
std::cout << " *** Feature flag '" << FEATURE_FLAG_KEY << " ' is "
63
63
<< (flag_value ? " true" : " false" ) << " for this user\n\n " ;
64
64
65
- for (int i = 0 ; i < 5 ; i++) {
66
- auto user_key = " example-user-key-" + std::to_string (i);
67
- auto context2 =
68
- ContextBuilder ().Kind (" user" , user_key).Name (" Bob" ).Build ();
69
-
70
- std::cout << " identifying " << user_key << std::endl;
71
- auto fut = client.IdentifyAsync (context2);
72
- fut.wait ();
73
- std::cout << " identified " << user_key << " !" << std::endl;
74
-
75
- std::this_thread::sleep_for (std::chrono::seconds (5 ));
76
- }
77
-
78
65
return 0 ;
79
66
}
80
67
Original file line number Diff line number Diff line change @@ -340,8 +340,28 @@ class FoxyClient : public Client,
340
340
shutting_down_ = true ;
341
341
// If any backoff is taking place, cancel that as well.
342
342
backoff_timer_.cancel ();
343
-
344
- boost::system::error_code ec = {};
343
+
344
+ // Cancels the outstanding read.
345
+ if (session_->stream .is_ssl ()) {
346
+ session_->stream .ssl ().next_layer ().cancel ();
347
+ } else {
348
+ session_->stream .plain ().cancel ();
349
+ }
350
+
351
+ // Ideally we would call session_->async_shutdown() here to gracefully
352
+ // terminate the SSL session. For unknown reasons, this call appears to
353
+ // hang indefinitely and never complete until the SDK client is
354
+ // destroyed.
355
+ //
356
+ // A workaround is to set a timeout on the operation, say 1 second. This
357
+ // gives the opportunity to shutdown gracefully and then if that fails,
358
+ // we could close the socket directly. But that also doesn't seem to
359
+ // work: even with the timeout, the operation still doesn't complete.
360
+ //
361
+ // So the most robust solution appears to be closing the socket
362
+ // directly. This is not ideal because it doesn't send a close_notify to
363
+ // the server.
364
+ boost::system::error_code ec;
345
365
session_->stream .plain ().shutdown (
346
366
boost::asio::ip::tcp::socket::shutdown_both, ec);
347
367
session_->stream .plain ().close (ec);
You can’t perform that action at this time.
0 commit comments