mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Add server/connection tests (RIPD-1336):
Migrate tests in uniport-test.js to cpp/jtx. Handle exceptions in WSClient and JSONRPClient constructors. Use shorter timeout for HTTP and WS Peers when client is localhost. Add missing call to start_timer in HTTP Peer. Add incomplete WS Upgrade request test to prove that server timeout is working.
This commit is contained in:
committed by
Nik Bougalis
parent
7ff243ade9
commit
8d83aa5c07
@@ -64,7 +64,8 @@ protected:
|
||||
bufferSize = 4 * 1024,
|
||||
|
||||
// Max seconds without completing a message
|
||||
timeoutSeconds = 30
|
||||
timeoutSeconds = 30,
|
||||
timeoutSecondsLocal = 3 //used for localhost clients
|
||||
};
|
||||
|
||||
struct buffer
|
||||
@@ -277,7 +278,12 @@ BaseHTTPPeer<Handler, Impl>::
|
||||
start_timer()
|
||||
{
|
||||
error_code ec;
|
||||
timer_.expires_from_now(std::chrono::seconds(timeoutSeconds), ec);
|
||||
timer_.expires_from_now(
|
||||
std::chrono::seconds(
|
||||
remote_address_.address().is_loopback() ?
|
||||
timeoutSecondsLocal :
|
||||
timeoutSeconds),
|
||||
ec);
|
||||
if(ec)
|
||||
return fail(ec, "start_timer");
|
||||
timer_.async_wait(strand_.wrap(std::bind(
|
||||
@@ -318,6 +324,7 @@ do_read(yield_context do_yield)
|
||||
{
|
||||
complete_ = false;
|
||||
error_code ec;
|
||||
start_timer();
|
||||
beast::http::async_read(impl().stream_,
|
||||
read_buf_, message_, do_yield[ec]);
|
||||
// VFALCO What if the connection was closed?
|
||||
|
||||
@@ -364,8 +364,11 @@ start_timer()
|
||||
{
|
||||
// Max seconds without completing a message
|
||||
static constexpr std::chrono::seconds timeout{30};
|
||||
static constexpr std::chrono::seconds timeoutLocal{3};
|
||||
error_code ec;
|
||||
timer_.expires_from_now(timeout, ec);
|
||||
timer_.expires_from_now(
|
||||
remote_endpoint().address().is_loopback() ? timeoutLocal : timeout,
|
||||
ec);
|
||||
if(ec)
|
||||
return fail(ec, "start_timer");
|
||||
timer_.async_wait(strand_.wrap(std::bind(
|
||||
|
||||
Reference in New Issue
Block a user