import weaviate
from weaviate.connect import ConnectionParams
from weaviate.classes.init import AdditionalConfig, Timeout
import os
client = weaviate.WeaviateClient(
connection_params=ConnectionParams.from_params(
http_host="localhost",
http_port="8099",
http_secure=False,
grpc_host="localhost",
grpc_port="50052",
grpc_secure=False,
),
auth_client_secret=weaviate.auth.AuthApiKey("secr3tk3y"),
additional_headers={
"X-OpenAI-Api-Key": os.getenv("OPENAI_APIKEY")
},
additional_config=AdditionalConfig(
timeout=Timeout(init=2, query=45, insert=120), # Values in seconds
),
)
client.connect()
Hi!
You shouldn’t include the schema/protocol on the url host.
this is an example of the code you posted that will work, for example, with our cloud services:
import weaviate
from weaviate.connect import ConnectionParams
from weaviate.classes.init import AdditionalConfig, Timeout
import os
client = weaviate.WeaviateClient(
connection_params=ConnectionParams.from_params(
http_host="3lhcpqlpqje13fdggbzpmg.c1-1.europe-west3.gcp.weaviate.cloud",
http_port="443",
http_secure=True,
grpc_host="grpc-3lhcpqlpqje13fdggbzpmg.c1-1.europe-west3.gcp.weaviate.cloud",
grpc_port="443",
grpc_secure=True,
),
auth_client_secret=weaviate.auth.AuthApiKey("Z......3"),
additional_headers={
"X-OpenAI-Api-Key": os.getenv("OPENAI_APIKEY")
},
additional_config=AdditionalConfig(
timeout=Timeout(init=2, query=45, insert=120), # Values in seconds
),
)
client.connect()
Let me know if this helps!
THanks!
Thank you so much helping me with the issues, I am clear now.
Can I ask you some suggestion to fix client connect issues with python v4? I struggle with it for two days
Scenario:
Weaviate instance in hosted in AWS Kubernetes.
when I use weaviate.WeaviateClient() to connect with it with the correct patten of url host as your mentioned , I got “httpcore.ConnectTimeout: timed out” and "httpx.ConnectTimeout: timed out " error, how to fix it?
Can I set http_host and grpc_host with the same url host?
Thanks in advance.
Hi! This seems like a deployment issue rather than a client issue.
After self deploying, using docker or k8s, for example, it is up to the sys admin to properly expose Weaviate under a TLS/SSL connection.
If exposing at all, as some users keep Weaviate under a backend, only exposing the backend.
So while exposing the service, in k8s for example, you can keep the same url for both grpc and http, or use different ones, but it need to be handled accordingly by your k8s load balance.
Have you used our helm chart for this deployment?
No, I did not use helm chart for this deployment.
I have gitlab repository to configure Kubernes, the files used to configure port 8080 and 50051 inside these five files:
kustomization.yaml
, service.yaml
, deployment.yaml
, ingress.yaml
, Dockerfile
.
Dose use helm chart to deploy will solve my issues?
Based on my current deploy solution, can you give me some suggestion to solve my problem?
I have only used our helm chart for deployment so not sure what could be happening there with a custom deployment.
Can you try deploying using the helm chart? Or trying to check the helm for something different it may have be doing?
Thank you so much for your help, let me try it