diff --git a/arangosh/Shell/V8ClientConnection.cpp b/arangosh/Shell/V8ClientConnection.cpp index ec11aa047e..81b2ba7494 100644 --- a/arangosh/Shell/V8ClientConnection.cpp +++ b/arangosh/Shell/V8ClientConnection.cpp @@ -75,16 +75,18 @@ V8ClientConnection::~V8ClientConnection() { void V8ClientConnection::createConnection() { - _connection = _builder.connect(_loop); - + auto newConnection = _builder.connect(_loop); fuerte::StringMap params{{"details","true"}}; auto req = fuerte::createRequest(fuerte::RestVerb::Get, "/_api/version", params); req->header.database = _databaseName; + req->timeout(std::chrono::seconds(30)); try { - auto res = _connection->sendRequest(std::move(req)); + auto res = newConnection->sendRequest(std::move(req)); _lastHttpReturnCode = res->statusCode(); if (_lastHttpReturnCode == 200) { + _connection = std::move(newConnection); + std::shared_ptr parsedBody; VPackSlice body; if (res->contentType() == fuerte::ContentType::VPack) { @@ -139,7 +141,10 @@ void V8ClientConnection::setInterrupted(bool interrupted) { } bool V8ClientConnection::isConnected() { - return _connection->state() == fuerte::Connection::State::Connected; + if (_connection) { + return _connection->state() == fuerte::Connection::State::Connected; + } + return false; } std::string V8ClientConnection::endpointSpecification() const { @@ -177,6 +182,9 @@ void V8ClientConnection::reconnect(ClientFeature* client) { _builder.authenticationType(fuerte::AuthenticationType::Jwt); } try { + if (_connection) { + _connection->cancel(); + } createConnection(); } catch (...) { std::string errorMessage = "error in '" + client->endpoint() + "'"; diff --git a/js/server/tests/resilience/moving-shards-with-arangosearch-view-cluster.js b/js/server/tests/resilience/moving-shards-with-arangosearch-view-cluster.js index ae21dd8eca..936315bc6e 100644 --- a/js/server/tests/resilience/moving-shards-with-arangosearch-view-cluster.js +++ b/js/server/tests/resilience/moving-shards-with-arangosearch-view-cluster.js @@ -553,7 +553,8 @@ function MovingShardsWithViewSuite (options) { v[i].drop(); c[i].drop(); } - c = [], v = []; + c = []; + v = []; resetCleanedOutServers(); }, diff --git a/js/server/tests/resilience/resilience-synchronous-repl-with-arangosearch-view-cluster.js b/js/server/tests/resilience/resilience-synchronous-repl-with-arangosearch-view-cluster.js index 100134cf61..a27b8b0521 100644 --- a/js/server/tests/resilience/resilience-synchronous-repl-with-arangosearch-view-cluster.js +++ b/js/server/tests/resilience/resilience-synchronous-repl-with-arangosearch-view-cluster.js @@ -200,7 +200,7 @@ function SynchronousReplicationWithViewSuite () { viewOperations("assert", null, function assert() { assertEqual( viewOperations("query", { query: "FOR d IN @@vn COLLECT WITH COUNT into iCount RETURN iCount", - bind: '{ "@vn" : name }' }).toArray()[0], 1) } ); + bind: '{ "@vn" : name }' }).toArray()[0], 1); } ); if (healing.place === 1) { healFailure(healing); } if (failure.place === 2) { makeFailure(failure); }