Skip to content

Conversation

@databyjp
Copy link
Collaborator

This PR updates error messages for:

  • The start-up REST connection error, which can occur at startup as the client checks for OIDC details
  • gRPC health check errors, by
    • Distinguishing gRPC & REST connections for the user
    • Including the gRPC url/port in the error message & suggesting the user check those
    • Suggest whether there may be a firewall

@databyjp
Copy link
Collaborator Author

databyjp commented Apr 25, 2024

Tested by running this to simulate a slow/unresponsive connection:

import socket
import time

# Create a TCP/IP socket
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_address = ('localhost', 12345)
server_socket.bind(server_address)
server_socket.listen(1)

print('Server listening on {}:{}'.format(*server_address))

while True:
    print('Waiting for a connection...')
    connection, client_address = server_socket.accept()
    try:
        print('Connection from', client_address)

        # Receive data and simulate a delay
        data = connection.recv(1024)
        print('Received:', data)
        time.sleep(100)  # Simulate 1 second delay

        # Send a response
        connection.sendall(b'Response from the server')
    finally:
        connection.close()

And various connections scenarios:

import time
import weaviate
from weaviate.classes.init import Timeout, AdditionalConfig, Auth
import time

def run_weaviate():
    for (port, grpc_port, timeout, auth) in [
        (8080, 50051, 2, None), # Correct, no auth
        (8080, 50051, 2, Auth.api_key("12345")), # Correct, wrong auth
        (12345, 50051, 2, None), # REST Black hole
        (8080, 12345, 2, None), # gRPC Black hole
        (1111, 50051, 2, None), # Incorrect REST
        (8080, 1111, 2, None), # Incorrect gRPC
    ]:
        print(f"\n")
        print(f"=" * 80)
        print(f"port={port}, grpc_port={grpc_port}, timeout={timeout}")
        print(f"=" * 80)
        print(f"\n")
        starttime = time.time()
        try:
            client = weaviate.connect_to_local(
                port=port,
                grpc_port=grpc_port,
                auth_credentials=auth,
                additional_config=AdditionalConfig(
                    timeout=Timeout(init=timeout, insert=5)  # Set grpc timeout to 2 seconds, rest timeout to 5 seconds
                )
            )

            assert client.is_ready()
            print("Weaviate is ready")
            client.close()
        except Exception as e:
            print(e)
        print("Time taken: ", time.time() - starttime)
    return True


if __name__ == '__main__':

    run_weaviate()

@tsmith023 tsmith023 merged commit 1a834a1 into main Apr 26, 2024
@tsmith023 tsmith023 deleted the dx/update-connection-error-msgs branch April 26, 2024 13:42
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.

3 participants