Add a heartbeat to detect hung connections (#1101)

* disconnect is now reconnect on heartbeat fail
This commit is contained in:
FKSRipple
2019-12-14 10:23:09 -08:00
committed by Elliot Lee
parent 5f92b230aa
commit 439a611a9e
3 changed files with 65 additions and 3 deletions

View File

@@ -336,6 +336,19 @@ export function createMockRippled(port) {
}
});
mock.on('request_ping', function (request, conn) {
// NOTE: We give the response a timeout of 2 second, so that tests can
// set their timeout threshold to greater than or less than this number
// to test timeouts.
setTimeout(() => {
conn.send(createResponse(request, {
"result": {},
"status": "success",
"type": "response"
}));
}, 1000 * 2);
});
mock.on('request_tx', function (request, conn) {
assert.strictEqual(request.command, 'tx');
if (request.transaction === hashes.VALID_TRANSACTION_HASH) {