Skip to content

Commit 0ef2fd9

Browse files
authored
ATSK-120 fix retries on stopping the robot within controller manager (ros-industrial#62)
* ATSK-0 review fixes * ATSK-0 quick fix
1 parent 343ad17 commit 0ef2fd9

File tree

4 files changed

+15
-61
lines changed

4 files changed

+15
-61
lines changed

include/abb_librws/connection_options.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,13 @@ namespace abb :: rws
1111
{
1212
struct ConnectionOptions
1313
{
14-
ConnectionOptions(std::string const& ip_address,
14+
ConnectionOptions(std::string ip_address,
1515
unsigned short port,
16-
std::string const& username,
16+
std::string username,
1717
std::string password,
1818
std::chrono::microseconds connection_timeout = std::chrono::milliseconds {400},
1919
std::chrono::microseconds send_timeout = std::chrono::milliseconds {400},
20-
std::chrono::microseconds receive_timeout = std::chrono::milliseconds {400},
21-
std::list<std::chrono::milliseconds> retry_backoff = std::list<std::chrono::milliseconds> {});
20+
std::chrono::microseconds receive_timeout = std::chrono::milliseconds {400});
2221

2322
/// \brief Robot controller's IP address.
2423
std::string ip_address;
@@ -40,8 +39,5 @@ namespace abb :: rws
4039

4140
/// \brief HTTP receive timeout
4241
std::chrono::microseconds receive_timeout;
43-
44-
/// \brief HTTP backoff time between retry
45-
std::list<std::chrono::milliseconds> retry_backoff;
4642
};
4743
}

include/abb_librws/v2_0/rws_client.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class RWSClient
8282
*
8383
* \throw \a RWSError if something goes wrong.
8484
*/
85-
explicit RWSClient(ConnectionOptions const& connection_options);
85+
explicit RWSClient(ConnectionOptions connection_options);
8686

8787
/**
8888
* \brief Logs out the currently active RWS session.

src/connection_options.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
#include <abb_librws/connection_options.h>
22

3+
#include <utility>
4+
35

46
namespace abb :: rws
57
{
68
ConnectionOptions::ConnectionOptions(
7-
std::string const& ip_address,
9+
std::string ip_address,
810
unsigned short port,
9-
std::string const& username,
11+
std::string username,
1012
std::string password,
1113
std::chrono::microseconds connection_timeout,
1214
std::chrono::microseconds send_timeout,
13-
std::chrono::microseconds receive_timeout,
14-
std::list<std::chrono::milliseconds> retry_backoff
15+
std::chrono::microseconds receive_timeout
1516
)
16-
: ip_address {ip_address}
17+
: ip_address {std::move(ip_address)}
1718
, port {port}
18-
, username {username}
19-
, password {password}
19+
, username {std::move(username)}
20+
, password {std::move(password)}
2021
, connection_timeout {connection_timeout}
2122
, send_timeout {send_timeout}
2223
, receive_timeout {receive_timeout}
23-
, retry_backoff {retry_backoff}
2424
{
2525
}
2626
}

src/v2_0/rws_client.cpp

Lines changed: 3 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,10 @@
4949
#include <stdexcept>
5050
#include <iostream>
5151
#include <thread>
52+
#include <utility>
5253

5354
#include <unistd.h>
5455

55-
56-
namespace
57-
{
58-
static const char EXCEPTION_CREATE_STRING[]{"Failed to create string"};
59-
}
60-
6156
namespace abb :: rws :: v2_0
6257
{
6358
using namespace Poco::Net;
@@ -70,8 +65,8 @@ using namespace Poco::Net;
7065
* Primary methods
7166
*/
7267

73-
RWSClient::RWSClient(ConnectionOptions const& connection_options)
74-
: connectionOptions_ {connection_options}
68+
RWSClient::RWSClient(ConnectionOptions connection_options)
69+
: connectionOptions_ {std::move(connection_options)}
7570
, context_ {
7671
new Poco::Net::Context {
7772
Poco::Net::Context::CLIENT_USE, "", "", "", Poco::Net::Context::VERIFY_NONE, 9, false, "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH"
@@ -326,13 +321,6 @@ POCOResult RWSClient::httpGet(const std::string& uri,
326321
std::set<Poco::Net::HTTPResponse::HTTPStatus> const& accepted_status)
327322
{
328323
POCOResult result = http_client_.httpGet(uri);
329-
std::list<std::chrono::milliseconds>::const_iterator it=connectionOptions_.retry_backoff.begin();
330-
331-
while (result.httpStatus() == HTTPResponse::HTTP_SERVICE_UNAVAILABLE && it != connectionOptions_.retry_backoff.end()){
332-
std::this_thread::sleep_for(*(it++));
333-
BOOST_LOG_TRIVIAL(warning) << "Received status 503 for " << uri << " doing retry";
334-
result = http_client_.httpGet(uri);
335-
}
336324

337325
if (accepted_status.find(result.httpStatus()) == accepted_status.end())
338326
{
@@ -355,14 +343,6 @@ POCOResult RWSClient::httpPost(const std::string& uri, const std::string& conten
355343
std::set<Poco::Net::HTTPResponse::HTTPStatus> const& accepted_status)
356344
{
357345
POCOResult result = http_client_.httpPost(uri, content, content_type);
358-
std::list<std::chrono::milliseconds>::const_iterator it=connectionOptions_.retry_backoff.begin();
359-
360-
while (shouldRetryPost(result.httpStatus()) && it != connectionOptions_.retry_backoff.end()){
361-
std::this_thread::sleep_for(*(it++));
362-
BOOST_LOG_TRIVIAL(warning) << "Received status " << result.httpStatus()
363-
<< " for " << uri << " doing retry. Response is: " << result.content();
364-
result = http_client_.httpPost(uri, content, content_type);
365-
}
366346

367347
if (accepted_status.find(result.httpStatus()) == accepted_status.end())
368348
{
@@ -385,13 +365,6 @@ POCOResult RWSClient::httpPut(const std::string& uri, const std::string& content
385365
std::set<Poco::Net::HTTPResponse::HTTPStatus> const& accepted_status)
386366
{
387367
POCOResult result = http_client_.httpPut(uri, content, content_type);
388-
std::list<std::chrono::milliseconds>::const_iterator it=connectionOptions_.retry_backoff.begin();
389-
390-
while (result.httpStatus() == HTTPResponse::HTTP_SERVICE_UNAVAILABLE && it != connectionOptions_.retry_backoff.end()){
391-
std::this_thread::sleep_for(*(it++));
392-
BOOST_LOG_TRIVIAL(warning) << "Received status 503 for " << uri << " doing retry";
393-
result = http_client_.httpPut(uri, content, content_type);
394-
}
395368

396369
if (accepted_status.find(result.httpStatus()) == accepted_status.end())
397370
{
@@ -415,13 +388,6 @@ POCOResult RWSClient::httpDelete(const std::string& uri,
415388
std::set<Poco::Net::HTTPResponse::HTTPStatus> const& accepted_status)
416389
{
417390
POCOResult result = http_client_.httpDelete(uri);
418-
std::list<std::chrono::milliseconds>::const_iterator it=connectionOptions_.retry_backoff.begin();
419-
420-
while (result.httpStatus() == HTTPResponse::HTTP_SERVICE_UNAVAILABLE && it != connectionOptions_.retry_backoff.end()){
421-
std::this_thread::sleep_for(*(it++));
422-
BOOST_LOG_TRIVIAL(warning) << "Received status 503 for " << uri << " doing retry";
423-
result = http_client_.httpDelete(uri);
424-
}
425391

426392
if (accepted_status.find(result.httpStatus()) == accepted_status.end())
427393
{
@@ -445,12 +411,4 @@ Poco::Net::WebSocket RWSClient::receiveSubscription(std::string const& subscript
445411
return http_client_.webSocketConnect("/poll/" + subscription_group_id, "rws_subscription",
446412
Poco::Net::HTTPSClientSession {connectionOptions_.ip_address, connectionOptions_.port, context_});
447413
}
448-
449-
450-
bool RWSClient::shouldRetryPost(Poco::Net::HTTPResponse::HTTPStatus status)
451-
{
452-
return status == HTTPResponse::HTTP_SERVICE_UNAVAILABLE //Received when robot server is busy and not able to respond now
453-
|| status == HTTPResponse::HTTP_FORBIDDEN; //Received e.g. when robot is updating rapid data and the resource is held by robot
454-
//or when rapid execution is stopping and we try to reset PP
455-
}
456414
}

0 commit comments

Comments
 (0)