Connect to weaviate through v4

Description

I need to use v4 to connect my weaviate through ingress.
If i use internal url, it works:

client = weaviate.WeaviateClient(
    connection_params=ConnectionParams.from_params(
        http_host="weaviate.testns.svc.cluster.local",
        http_port="80",
        http_secure=False,        
        grpc_host="weaviate-test-grpc.datalake.c.eu-nl-1.cloud.sap",
        grpc_port="443",
        grpc_secure=False,
    ),
    auth_client_secret=weaviate.auth.AuthApiKey("jane-secret-key"),
    # additional_headers={
    #     "X-OpenAI-Api-Key": os.getenv("OPENAI_APIKEY")
    # },
    additional_config=weaviate.config.AdditionalConfig(
        startup_period=10,
        timeout=(5, 15)  # Values in seconds
    ),
)

If i changed to external ingress it failed.

client = weaviate.WeaviateClient(
    connection_params=ConnectionParams.from_params(
        http_host="weaviate-test.mydomain.com,
        http_port="443",
        http_secure=False,
        grpc_host="weaviate-test-grpc.mydomain.com",
        grpc_port="443",
        grpc_secure=False,
    ),
    auth_client_secret=weaviate.auth.AuthApiKey("jane-secret-key"),
    # additional_headers={
    #     "X-OpenAI-Api-Key": os.getenv("OPENAI_APIKEY")
    # },
    additional_config=weaviate.config.AdditionalConfig(
        startup_period=10,
        timeout=(5, 15)  # Values in seconds
    ),
)

Of course i tested both:

curl https://ssdl-weaviate-test.mydomain.com/v1
and
grpcurl -d ‘{“service”: “Weaviate”}’ health.proto weaviate-test-grpc.mydomain.com:443 grpc.health.v1.Health/Check

Both are working without error.

Server Setup Information

  • Weaviate Server Version: the latest from helm, 1.24.8
  • Deployment Method: k8s
  • Multi Node? Number of Running Nodes: 1
  • Client Language and Version: Python weaviate-client==4.5.5

Any additional Information

The error from python code are:

Traceback (most recent call last):
  File "/Users/alan/weaviate-demo/pythonProject/.venv/lib/python3.9/site-packages/weaviate/connect/v4.py", line 141, in connect
    self._weaviate_version = _ServerVersion.from_string(self.get_meta()["version"])
  File "/Users/alan/weaviate-demo/pythonProject/.venv/lib/python3.9/site-packages/weaviate/connect/v4.py", line 579, in get_meta
    res = _decode_json_response_dict(response, "Meta endpoint")
  File "/Users/alan/weaviate-demo/pythonProject/.venv/lib/python3.9/site-packages/weaviate/util.py", line 929, in _decode_json_response_dict
    raise UnexpectedStatusCodeError(location, response)
weaviate.exceptions.UnexpectedStatusCodeError: Meta endpoint! Unexpected status code: 400, with response body: None.

Hi @Alan ! Welcome to our community! :hugs:

have you tried with http_secure=True, and grpc_secure=True?

Maybe your ingress will only accept https connections?

Let me know if this helps!

Thanks!

Hi @DudaNogueira ,
Thanks for your reply.
My ingress should allow insecure connection.
My ingress is company signed, if i turn on, it will threw self-signed cert errors. Can you advice how can I pass my crt file in the connection?

Finally we found solution:
Before the call, we need to add below which containing our self-signed ca.

os.environ["GRPC_DEFAULT_SSL_ROOTS_FILE_PATH"] = "/home/jovyan/cert.crt"
os.environ["SSL_CERT_FILE"] = "/home/jovyan/cert.crt"
1 Like

Awesome, @Alan_Sun !

Thanks for sharing!