Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't connect to a mongo cluster which address is behind a haproxy. #478

Closed
WindSoilder opened this issue Sep 30, 2021 · 3 comments
Closed

Comments

@WindSoilder
Copy link
Contributor

WindSoilder commented Sep 30, 2021

Reproducing code:

use mongodb::sync::Client;
use bson::{Document};

fn main() {
    let cli = Client::with_uri_str("mongodb://xxx:[email protected]:37017").unwrap();
    let db = cli.database("local");
    let coll = db.collection::<Document>("oplog.rs");
    println!("{:?}", coll.find_one(None, None).unwrap());
}

When I'm trying to find, it returns an error:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error { kind: ServerSelection { message: "Server selection timeout: No available servers. Topology: { Type: Unknown, Servers: [ { Address: 192.168.10.11:37017, Type: Unknown, Error: unexpected end of file }, ] }" }, labels: {} }', src/bin/test.rs:8:48

Using pymongo or mongo shell doesn't have this problem:

图片
The address of mongodb is a haproxy to real mongodb address. When the ip is not behind a ha proxy, the code works fine.

Database version: 3.2.22

It also seems that the expected tpoplogy type is single:
图片

@WindSoilder
Copy link
Contributor Author

WindSoilder commented Sep 30, 2021

Oh, I got the reason, it seems that the driver doesn't support mongodb older than 3.6.....
https://docs.mongodb.com/drivers/rust/

A little curious about why ? It seems that many other drivers support mongodb 3.2+..

@kmahar
Copy link
Contributor

kmahar commented Sep 30, 2021

Hi @WindSoilder!

The Rust driver is the newest MongoDB driver, and only did our 1.0 release a little over a year ago.

From a development perspective, the effort to support server versions both < 3.6 and 3.6+ at once is quite significant due to changes that occurred in 3.6 in how drivers interact with the underlying MongoDB server via the wire protocol, as well as the introduction of sessions support in MongoDB 3.6. I would also note that at the time of our 1.0 release all MongoDB versions < 3.6 had already reached end-of-life. (see: https://www.mongodb.com/support-policy/lifecycles).

Given that, we made the choice to only support 3.6+ and instead focus our development efforts on adding support for newer MongoDB features (e.g. sessions, transactions) along with making the driver performant and addressing the needs of Rust developers through e.g. Serde integration, supporting multiple async runtimes, etc.

@WindSoilder
Copy link
Contributor Author

Oh, I get it, thanks for your detailed explanation, I think it can be closed :-) Thank you.

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

No branches or pull requests

2 participants