Is there a way to do this?
I don't think there is any other way of doing this than by sending a plot and monitoring the response obtained in https://github.com/facebookresearch/visdom/blob/master/py/__init__.py#L242
Feel free to add a check_connection that creates an empty plot and closes it again to check the connection.
Expect a PR soon, the python side is complete but not the torch side; I have been unable to successfully setup torch on my machine. I opened an issue on the torch7 issue tracker but I have not heard back yet.
Hi @jkarimi91, as of 1753e20f4ba805cb94d3646d472c53bc8d990a2a we've converted the Lua code to be a wrapper around the python code, so the python code is certainly more valuable.
Thanks @JackUrb; expect a PR tomorrow.
This functionality was added in https://github.com/facebookresearch/visdom/commit/0d1e78bc6b99cabb9861ccbd598bfe978b59399f. You can now call viz.check_connection() to see if the server is connected.
Checking connection before starting a server needs a Visdom object to be able to call viz.check_connection(), yet instantiating a Visdom object needs an already running server.
Any chance of making the check_connection a static method?
It would be possible to create a static version of the check_connection method that takes in the arguments that the current version is able to pull from the existing object, using the defaults if none are given, however I feel this is a different use case from what the current method tries to do. I'd be open to a PR that implements a static check_server_active or something with documentation for why it exists and is distinct from check_connection though.
I worked my way around it with this small snippet, maybe it will be of some help
def socket_is_used(port, hostname):
is_used = False
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
s.bind((hostname, port))
except socket.error:
is_used = True
finally:
s.close()
return is_used
Most helpful comment
I worked my way around it with this small snippet, maybe it will be of some help