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

Dealing with timeouts #2

Open
ralmond opened this issue Jan 23, 2022 · 2 comments
Open

Dealing with timeouts #2

ralmond opened this issue Jan 23, 2022 · 2 comments

Comments

@ralmond
Copy link

ralmond commented Jan 23, 2022

Thanks for making this sample code available. However, it reproduces a problem I've been having and am looking for a solution to.
When I run the code, but don't connect a client within 60 seconds I get the following error message.

> server()

Listening...
Error in socketConnection(host = "localhost", port = 6011, blocking = TRUE,  : 
  cannot open the connection
In addition: Warning message:
In socketConnection(host = "localhost", port = 6011, blocking = TRUE,  :
  problem in listening on this socket
> 

I'm pretty sure that the problem here is a timeout, but I'm looking for an example of a server that will robustly wait for the connection and not just bug out after a mere minute.

Do you have experience with this?

@corynissen
Copy link
Owner

corynissen commented Jan 24, 2022

The default timeout is set by getOption("timeout"). It looks like you should be able to set it to whatever you'd like:

con <- socketConnection(host="localhost", port = 6011, blocking=TRUE, server=TRUE, 
                        open="r+", timeout = 123456789)

@ralmond
Copy link
Author

ralmond commented Jan 24, 2022

I was hoping for a more robust example that after a timeout would check for a shutdown flag and then reopen the connection.

I suppose could set this up using try, but the exceptions that socketConnection throws are not well documented.

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

No branches or pull requests

2 participants