qdrant / rust-client

Rust client for Qdrant vector search engine
https://crates.io/crates/qdrant-client
Apache License 2.0
222 stars 45 forks source link

Failed to connect #162

Closed AspadaX closed 3 months ago

AspadaX commented 3 months ago

Below is the error message I received. I am coding an actix-web service and one part of it is to store vectors into Qdrant. But the Rust Qdrant does not connect to the database. The curl was okay on both 6333 and 6334. [2024-07-08T10:50:25Z ERROR rust_backend::utilities::vector_database_interfaces] ResponseError { status: Status { code: Internal, message: "Failed to connect to 0.0.0.0:6334: transport error", source: None } }

Below is a sample code that generates the error:

use qdrant_client::qdrant::{vectors_config::Config, VectorParams, VectorsConfig, CreateCollection, Distance};

#[tokio::main]
async fn main() {
    // initialize a qdrant client
    let client = qdrant_client::Qdrant::from_url(
        "192.168.0.101:6334"
    )
        .build()
        .expect("Cannot initiate the client");

    // create a collection for storing documents
    match client.create_collection(
        CreateCollection {
            collection_name: "test".to_string(),
            vectors_config: Some(
                VectorsConfig {
                    config: Some(
                        Config::Params(
                            VectorParams {
                                size: 1024,
                                distance: Distance::Cosine.into(),
                                ..Default::default()
                            }
                        )
                    ),
                }
            ),
            ..Default::default()
        }
    ).await {
        Ok(result) => println!("{:?}", result), 
        Err(error) => {
            println!("{:?}", error);
        }
    };
}

I am not sure, maybe something went wrong on my end?

AspadaX commented 3 months ago

I think that I spotted the issue.

The url should be written as http://localhost:6334 instead of localhost:6334.