Discussion:
[asio-users] timeout for ssl_stream::async_shutdown()?
Adam Crain
2017-02-22 21:48:45 UTC
Permalink
When shutting down a ssl_stream asynchronously, what happens if the remote
side never responds? Does the callback handler never fire?

http://think-async.com/Asio/asio-1.10.6/doc/asio/reference/ssl__stream/async_shutdown.html

-Adam
--
J Adam Crain - Partner

<http://www.automatak.com>

PGP 4096R/E2984A0C <https://www.automatak.com/keys/jadamcrain.asc> 2013-05-03
Vinnie Falco
2017-02-22 22:22:52 UTC
Permalink
Post by Adam Crain
When shutting down a ssl_stream asynchronously, what happens if the remote
side never responds? Does the callback handler never fire?
http://think-async.com/Asio/asio-1.10.6/doc/asio/
reference/ssl__stream/async_shutdown.html
To my knowledge, no asynchronous Asio operations have built-in timeouts.
Its up to callers to set up a timer and cancel the I/O if the timer
expires. When canceling the I/O make sure you do it from the same implicit
or explicit strand that the completion handlers are using.

Disclaimer: I have not looked at the actual implementation for
ssl_stream::async_shutdown.
ivan kostov
2017-02-23 16:46:04 UTC
Permalink
I have a similar issue with async_write on a closed socket. In this case I
didn't found any way to return with an error. You can setup a c++11 future
and wait_for(timeout) on it.

if( future.wait_for(std::chrono::milliseconds(100))!=
std::future_status::ready )
{
// error handling
}
Post by Vinnie Falco
Post by Adam Crain
When shutting down a ssl_stream asynchronously, what happens if the
remote side never responds? Does the callback handler never fire?
http://think-async.com/Asio/asio-1.10.6/doc/asio/reference/
ssl__stream/async_shutdown.html
To my knowledge, no asynchronous Asio operations have built-in timeouts.
Its up to callers to set up a timer and cancel the I/O if the timer
expires. When canceling the I/O make sure you do it from the same implicit
or explicit strand that the completion handlers are using.
Disclaimer: I have not looked at the actual implementation for
ssl_stream::async_shutdown.
------------------------------------------------------------
------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
asio-users mailing list
https://lists.sourceforge.net/lists/listinfo/asio-users
_______________________________________________
Using Asio? List your project at
http://think-async.com/Asio/WhoIsUsingAsio
Adam Crain
2017-02-23 17:58:41 UTC
Permalink
thanks Vinnie and Ivan. So it's either block w/ timeout or use an
asynchronus timeout timer.

Blocking for me is out considering I don't wanted to tie up my event loop.
The timer would work, but I'm now weighing
having to add/test this version just slamming the socket shut and not
caring about the remote endpoint complaining about
the non-graceful SSL shutdown... It's really not a problem for the protocol
I'm wrapping.

-Adam
Post by ivan kostov
I have a similar issue with async_write on a closed socket. In this case I
didn't found any way to return with an error. You can setup a c++11 future
and wait_for(timeout) on it.
if( future.wait_for(std::chrono::milliseconds(100))!=
std::future_status::ready )
{
// error handling
}
Post by Vinnie Falco
Post by Adam Crain
When shutting down a ssl_stream asynchronously, what happens if the
remote side never responds? Does the callback handler never fire?
http://think-async.com/Asio/asio-1.10.6/doc/asio/reference/s
sl__stream/async_shutdown.html
To my knowledge, no asynchronous Asio operations have built-in timeouts.
Its up to callers to set up a timer and cancel the I/O if the timer
expires. When canceling the I/O make sure you do it from the same implicit
or explicit strand that the completion handlers are using.
Disclaimer: I have not looked at the actual implementation for
ssl_stream::async_shutdown.
------------------------------------------------------------
------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
asio-users mailing list
https://lists.sourceforge.net/lists/listinfo/asio-users
_______________________________________________
Using Asio? List your project at
http://think-async.com/Asio/WhoIsUsingAsio
------------------------------------------------------------
------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
asio-users mailing list
https://lists.sourceforge.net/lists/listinfo/asio-users
_______________________________________________
Using Asio? List your project at
http://think-async.com/Asio/WhoIsUsingAsio
--
J Adam Crain - Partner

<http://www.automatak.com>

PGP 4096R/E2984A0C <https://www.automatak.com/keys/jadamcrain.asc> 2013-05-03
Loading...