Rajat Singh
2013-02-28 04:40:29 UTC
In my application I am sending and receiving bulk of messages and behaving
as a server. In the meanwhile I check the session timeout of the client. My
program works fine when I don't use the asyn_wait in my application. but
when I use asyn_wait then my application gets crashed after sending and
receiving some 100,000 - 200,000 messages and following error comes.
"terminate called after throwing an instance of 'boost::exception_detail::
clone_impl<boost::exception_
detail::error_info_injector<boost::system::system_error> >' what():
asio.ssl error"
whenever server receive any message from client then it calls start().
void start()
{
this->resetTimer();
}
void resetTimer()
{
if (getSessionTimeout() > 0)
{
// timer of 10 seconds
_timer.expires_from_now(10);
_timer.async_wait(
_strand.wrap(
boost::bind(&Connection::handleTimeout,
shared_from_this(),
boost::asio::placeholders::error)
)
);
}
}
void handleTimeout(const boost::system::error_code &e)
{
if (!_loggedIn)
return;
if (!e)
{
boost::system::error_code ec;
boost::asio::ip::tcp::endpoint endpoint = socket().remote_endpoint(ec);
if (ec)
{
// some error has occured
this->close();
return;
}
else
{
_timeoutCount++;
std::string ping = "HI";
this->sendMessage(ping);
// no activity for quite some time now
// so we just disconnect the session
if (_timeoutCount > 10)
{
ERROR_1(TIMEOUT_OCCURED);
this->close();
}
else
this->start();
}
}
}
as a server. In the meanwhile I check the session timeout of the client. My
program works fine when I don't use the asyn_wait in my application. but
when I use asyn_wait then my application gets crashed after sending and
receiving some 100,000 - 200,000 messages and following error comes.
"terminate called after throwing an instance of 'boost::exception_detail::
clone_impl<boost::exception_
detail::error_info_injector<boost::system::system_error> >' what():
asio.ssl error"
whenever server receive any message from client then it calls start().
void start()
{
this->resetTimer();
}
void resetTimer()
{
if (getSessionTimeout() > 0)
{
// timer of 10 seconds
_timer.expires_from_now(10);
_timer.async_wait(
_strand.wrap(
boost::bind(&Connection::handleTimeout,
shared_from_this(),
boost::asio::placeholders::error)
)
);
}
}
void handleTimeout(const boost::system::error_code &e)
{
if (!_loggedIn)
return;
if (!e)
{
boost::system::error_code ec;
boost::asio::ip::tcp::endpoint endpoint = socket().remote_endpoint(ec);
if (ec)
{
// some error has occured
this->close();
return;
}
else
{
_timeoutCount++;
std::string ping = "HI";
this->sendMessage(ping);
// no activity for quite some time now
// so we just disconnect the session
if (_timeoutCount > 10)
{
ERROR_1(TIMEOUT_OCCURED);
this->close();
}
else
this->start();
}
}
}
--
*Rajat Singh*
*Rajat Singh*