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-
6156namespace abb :: rws :: v2_0
6257{
6358using 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