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

connection.ping seems to never timeout #27

Open
Jabulba opened this issue Oct 21, 2020 · 2 comments
Open

connection.ping seems to never timeout #27

Jabulba opened this issue Oct 21, 2020 · 2 comments

Comments

@Jabulba
Copy link

Jabulba commented Oct 21, 2020

The connection ping fn seems to never return when no connection to db is present. The sample code below hangs during the match for conn.ping() and never returns Ok nor Err

I was attempting to use the ping to check if the database is still available because we are having some network issues. Am I missing something here?

Sample code:

let conn = match Connection::connect(username, password, "localhost:1521/DB1") {
	Ok(c) => {c}
	Err(err) => {panic!("{:?}", err)}
};

let delay = std::time::Duration::from_secs(3);
loop {
	match conn.ping() {
		Ok(_) => { log::info!("Ping OK!"); }
		Err(err) => { log::info!("Ping Err: {:?}", err); }
	};

	std::thread::sleep(delay);
}
@kubo
Copy link
Owner

kubo commented Oct 25, 2020

connection.ping works when the network isn't in trouble.
It sends a ping packet and waits the reply. However it hangs until timeout when the reply is lost by network trouble.
Could you use SQLNET.RECV_TIMEOUT or Connection.set_call_timeout() added in v0.3.3?

@Jabulba
Copy link
Author

Jabulba commented Oct 27, 2020

I tried with the new Connection.set_call_timeout() and it works nicely, thanks for the quick update!
I think it would also be nice to be able to configure the Connector with this option! I can try to make a PR if you like, but I'm still somewhat new with Rust

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