inejge / ldap3

A pure-Rust LDAP library using the Tokio stack
Apache License 2.0
220 stars 38 forks source link

[Question] Either the application has not called WSAStartup, or WSAStartup failed. (os error 10093) #56

Closed Geobert closed 3 years ago

Geobert commented 3 years ago

Hi,

A user of my app using ldap3 just send me logs containing:

LDAP connection error: I/O error: Either the application has not called
WSAStartup, or WSAStartup failed. (os error 10093)

What does it mean?

inejge commented 3 years ago

That's the Winsock DLL initialization function, deep below the level on which ldap3 operates. There's a mention of it in tokio-rs/tokio-core#242, aloong with some speculation about thread shutdown order. That's old code, but maybe it can help you track down the issue.

I'll keep this open for a couple of days, but I'd prefer to close it later, resolved or not, since I don't think there's anything that can be done about it in this crate; it exposes the issue, but doesn't cause it.

Geobert commented 3 years ago

Thanks for your answer!

But ldap3 doesn't use tokio-core, does it?

inejge commented 3 years ago

It doesn't, but the linked issue is the closest analogue I can find. Look at Cargo.lock of the application: there is still the chain tokio -> mio -> net2 described in the issue, which calls WSAStartup during socket creation. You could try building the application with the modified net2, where the error result of UdpSocket::bind would be logged.

Geobert commented 3 years ago

True, and I found this: https://github.com/tokio-rs/mio/issues/1046 EDIT: and the issue was fixed by https://github.com/tokio-rs/mio/pull/1029

which removes net2

inejge commented 3 years ago

The dummy UDP socket creation has just moved to mio: here it is.

Geobert commented 3 years ago

I see, so what's happening is something bad in mio? I've seen the error message only once for the moment, and using ldap3 in conjunction with deadpool. And it was reported to me, I've never experienced it myself. Maybe rare.

inejge commented 3 years ago

It's probably some strange interaction of the user's environment with Winsock. Windows has gotten better in the past decade, but there are still problems which are best "solved" with one of three R's (restart/reboot/reinstall). Perhaps this is one of them. If it's reproducible, a low-level call trace ought to help.

Geobert commented 3 years ago

Let's close this then, nothing you can do about it anyway, thank you very much for your expertise!