graypy icon indicating copy to clipboard operation
graypy copied to clipboard

A way to check / test if connection is established?

Open alercelik opened this issue 3 years ago • 1 comments

Hello,

Is there a way to check if connection is established succesfully with the graylog server? I could not see any. Currently i give random ports to constructor and not get any errors thus I have no way to find out whether connection is established. It would be really helpful if there is a parameter or a method to indicate that.

alercelik avatar Jun 06 '22 13:06 alercelik

I'm using this snippet

  def check_connection(self):
        sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        result = sock.connect_ex((self.host, self.port))
        sock.close()
        if result == 0:
            return True
        return False

BeeStingBob avatar Feb 26 '23 22:02 BeeStingBob