Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConnectionTask: Fix request failure retrying #1106

Merged
merged 2 commits into from
Aug 7, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions source/agora/network/NetworkManager.d
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,14 @@ public class NetworkManager
key = client.getPublicKey();
break;
}
catch (HTTPStatusException ex)
catch (Exception ex)
{
// 404 => API not implemented, it's a FullNode
if (ex.status == 404)
break;
if (auto http = cast(HTTPStatusException)ex)
{
// 404 => API not implemented, it's a FullNode
if (http.status == 404)
break;
}
Geod24 marked this conversation as resolved.
Show resolved Hide resolved

if (!this.onFailedRequest(this.address))
return;
Expand Down
37 changes: 37 additions & 0 deletions source/agora/test/Timeout.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*******************************************************************************

Tests connection timeouts

Copyright:
Copyright (c) 2020 BOS Platform Foundation Korea
All rights reserved.

License:
MIT License. See LICENSE for details.

*******************************************************************************/

module agora.test.Timeout;

version (unittest):

import agora.api.Validator;
import agora.consensus.data.Transaction;
import agora.test.Base;

///
unittest
{
TestConf conf = { retry_delay : 1.msecs,
max_retries : 2,
timeout : 500.msecs,
max_failed_requests : 1000 }; // never ban
auto network = makeTestNetwork(conf);
auto nodes = network.clients;

nodes[$-1].ctrl.sleep(2.seconds, false);
network.start();
scope(exit) network.shutdown();
scope(failure) network.printLogs();
network.waitForDiscovery();
}