timkley / weaviate-php

A PHP client to communicate with a Weaviate instance
MIT License
26 stars 9 forks source link

Weaviate plugin giving connection refused with docker #3

Closed faizanmuzaffar12 closed 1 year ago

faizanmuzaffar12 commented 1 year ago

Hello everyone,

I had set up the weaviate with no authentication, and here's my docker-compose setting for weavaiate: ` weaviate: command:

My first problem is when using this package, the way it is developed, it required the API token as a required parameter. $weaviate = new Weaviate('http://0.0.0.0:8080/v1','api-token');, Now if I don't have any API token then how can I provide it here because it cannot be empty?

can anyone help me here:

Also, the weaviate is running I can access this URL on the browser but when i call its other function like:

dd($weaviate->dataObject()->get());

it gives me connection refused error.

is there anything I am missing here or do we need to work on that API token parameter?

timkley commented 1 year ago

@faizanmuzaffar12 hi 👋🏻

That's definitely an oversight on my side. The API token should not be mandatory. I'll make it nullable.

You should always be able to just provide any API token. If your Weaviate instance doesn't have authentication activated it should not be an issue.

For your other problem, connection refused doesn't sound like an authentication issue. Try to remove v1 from your host URL, this is not needed.

 $weaviate = new Weaviate('http://0.0.0.0:8080,'api-token');
faizanmuzaffar12 commented 1 year ago

Thanks @timkley for your reply.

But the thing is if i try the same thing like if create the instance like this using the weaviate cloud services authentication

$weaviate = new Weaviate(config('services.weaviate.url'),config('services.weaviate.key'));

and then call the function:

$weaviate->dataObject()->get()

it won't give me any errors and it will return all the data objects but when i added weaviate using docker and tried to access it, it gives me a connection refused error:

cURL error 7: Failed to connect to localhost port 8080 after 0 ms: Connection refused (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for http://localhost:8080/v1/objects

timkley commented 1 year ago

@faizanmuzaffar12 Connection refused issue: This problem can occur due to several reasons, but the most common ones are the service not running on the specified host and port, or a network issue. Check whether the Weaviate service is running correctly in the Docker container and that it's exposed on the correct host and port. You can use the command docker ps to check the running containers and their exposed ports. Also, instead of using 'localhost' or '0.0.0.0' in your Weaviate client instantiation, try using the IP address of the Docker host machine.

You should also check your Docker network configuration.

faizanmuzaffar12 commented 1 year ago

Hello @timkley, Thanks but i have already checked and service is already running by running the following command in my shell

curl localhost:8080/v1/meta it gives me the following response. {"hostname":"http://[::]:8080","modules":{},"version":"1.20.1"}

also same with the 0.0.0.0:8080/v1/meta.

Still Thanks for your help.

timkley commented 1 year ago

Did you remove v1 from the localhost-definition? Is your application maybe running in another network?

faizanmuzaffar12 commented 1 year ago

Yes, I tried removing the v1 from the localhost-definition it didn't work for me.

Also resolved the issue by changing the docker-compose configuration, the configuration that works for me is: ` weaviate: image: semitechnologies/weaviate:1.20.1 ports:

and then creating the new weaviate instance by:

$weaviate = new Weaviate('http://weaviate:8080/v1', '');

and now i can get and set the objects in the weaviate.

Thanks @timkley, it was more network configuration error.