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

added param for timeout, added retries #1008

Merged
merged 1 commit into from Aug 20, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 17 additions & 4 deletions moveit_ros/warehouse/warehouse/src/warehouse_services.cpp
Expand Up @@ -130,21 +130,34 @@ int main(int argc, char** argv)

ros::NodeHandle node;
std::string host;

int port;
float connection_timeout;
int connection_retries;

node.param<std::string>("warehouse_host", host, "localhost");
node.param<int>("warehouse_port", port, 33829);
node.param<float>("warehouse_db_connection_timeout", connection_timeout, 5.0);
node.param<int>("warehouse_db_connection_retries", connection_retries, 5);

warehouse_ros::DatabaseConnection::Ptr conn;

try
{
conn = moveit_warehouse::loadDatabase();
conn->setParams(host, port, 5.0);
conn->setParams(host, port, connection_timeout);

ROS_INFO("Connecting to warehouse on %s:%d", host.c_str(), port);
if (!conn->connect())
int tries = 0;
while (!conn->connect())
{
ROS_ERROR("Failed to connect to DB on %s:%d", host.c_str(), port);
return 1;
++tries;
ROS_WARN("Failed to connect to DB on %s:%d (try %d/%d).", host.c_str(), port, tries, connection_retries);
if (tries == connection_retries)
{
ROS_FATAL("Failed to connect too many times, giving up");
return 1;
}
}
}
catch (std::exception& ex)
Expand Down