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

Add send/ recv timeouts to message endpoints #119

Merged
merged 4 commits into from
Jun 18, 2021
Merged

Conversation

Shillaker
Copy link
Collaborator

@Shillaker Shillaker commented Jun 17, 2021

At the moment we don't set any timeouts in our use of 0MQ, which means we get an infinite hang if something goes wrong. Instead we would like things to time out, so this PR sets the send timeout and recv timeout on every 0MQ socket by default.

I actually can't work out in which scenario the send timeout would be triggered, hence there's no test for it and it could be overkill. However, for now I'd like to keep it in case it catches any of the issues we've been seeing.

@Shillaker Shillaker self-assigned this Jun 17, 2021
@Shillaker Shillaker marked this pull request as ready for review June 17, 2021 15:15
int recvTimeoutMs = DEFAULT_RECV_TIMEOUT_MS;
int sendTimeoutMs = DEFAULT_SEND_TIMEOUT_MS;

void validateTimeout(int value);
Copy link
Collaborator Author

@Shillaker Shillaker Jun 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These have to be protected because of the subclassing that goes on (otherwise they'd be private).


// Print default message and rethrow
SPDLOG_ERROR("Error receiving message: {} ({})", e.num(), e.what());
throw;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This message was missing the error code before.

@@ -163,4 +186,56 @@ TEST_CASE("Test multiple clients talking to one server", "[transport]")

server.stop();
}

TEST_CASE("Test client timeout on requests to valid server", "[transport]")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is the right place to put this test. It requires a custom server, but is really testing functionality in the client.

Copy link
Collaborator

@csegarragonz csegarragonz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Just one minor pint re. infinite timeouts.

@@ -253,6 +265,31 @@ int MessageEndpoint::getPort()
return port;
}

void MessageEndpoint::validateTimeout(int value)
{
if (value <= 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So how would we specify an infinte timeout? Do we want to support that at all? I would expect a negative timeout to not timeout at all.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not support infinite timeouts anywhere. I can't think of a case where it's justified.

@Shillaker Shillaker merged commit 12796a1 into master Jun 18, 2021
@Shillaker Shillaker deleted the endpoint-timeouts branch June 18, 2021 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants