Comments (3)
Huh that's surprising. I think you should never get this so long as the provided io
performs blocking I/O (like a TcpStream).
Could you share your code?
from ureq.
Sorry for the late reply, been busy. Will try to create a minimal example.
from ureq.
I found the issue, it happens when there's a really really slow server and the request times out while trying to do a tls handshake.
If you run the server and then start two clients at the same time, one of them will fail with "TimedOut" and the other with "WouldBlock", as the first one that starts will timeout reading the response while the other one times out during the tls handshake.
So it's not really a "bug" per se, ureq does what it is supposed to, but the "WouldBlock" error type is very confusing.
client
static ROOT_CERT_PEM : &str = r#"-----BEGIN CERTIFICATE-----
MIIDcTCCAlmgAwIBAgIURAwA7tQhPBDBQ88AeTljaZjwCbUwDQYJKoZIhvcNAQEL
BQAwTzELMAkGA1UEBhMCU0UxDzANBgNVBAgMBlNjYW5pYTENMAsGA1UEBwwETHVu
ZDENMAsGA1UECgwEQXhpczERMA8GA1UEAwwIdGVzdC5jb20wHhcNMjMxMTEyMTUy
MTA5WhcNMjQxMTEyMTUyMTA5WjBPMQswCQYDVQQGEwJTRTEPMA0GA1UECAwGU2Nh
bmlhMQ0wCwYDVQQHDARMdW5kMQ0wCwYDVQQKDARBeGlzMREwDwYDVQQDDAh0ZXN0
LmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAIjbuyzMmEbv+RAt
mfq747V+lGTSxMMbNe/o721Ybjt3aSigrazmO8TL9Qy33bWwVGRuizZCcomyJAML
8qPqp5yB6t9u0+jdnOFneQE3PDp5wpel0zUfj9HBhMTbL0NnS3fwTOYS9jGgy2VH
wCWPqT+0TxKBaomR+6khFXwSBOd6xpOfGy2Kb4bdTvMmSgO4jDJ9gHWUnjMuMiWq
mFswIu9ZqxtJoD9iJTC+NG2NlMWZDzTy/Eo6OVyJf6uBUdPEWpDz9cURFvu1QuxL
mKA3wP8l6Xlq17hPnkStzmZnKJCiuToVCjzbjT2fzJy/S3Iid+i1vD6yEV+WogCX
VFFMbM8CAwEAAaNFMEMwEgYDVR0TAQH/BAgwBgEB/wIBAjAOBgNVHQ8BAf8EBAMC
AQYwHQYDVR0OBBYEFAv8JD8ZmZX4RI7lzFHi8u4yS6KHMA0GCSqGSIb3DQEBCwUA
A4IBAQAhQAKFj3IXHjE5TsolKZzFsVFQcph7h76kyhj6nPmdg0rEmb6Qtg4HO5YU
4A+dGx0nJGPLAnLYmDIc7Pn+ZChsZcbcZbm+JBuHKYrueuLvr30lxB5KsoXsqKdB
ME/uFgkwxqdCmNidT6oG2y2TIo+qZKqBWmIgxGdkU73NkvtgQbuVDg3tHYemj0ni
E0NPBpWN0N1tkUO/zjnDnfx2Qog2R1I+XUG3jlikJgXMGhSlsmYifCTHKzuqSb7l
6FrT3Y5nzeBpEL4U9sv0i3JYFHglEwzXUsNBYXg5ejlpXUu4XiTXKgPCqMByVAWx
7KpMXzfJ7W2Zf2J9qJkD24CrKaKi
-----END CERTIFICATE-----"#;
fn request() {
let string = "abcde ".repeat(5);
let root_cert = native_tls::Certificate::from_pem(ROOT_CERT_PEM.as_bytes()).unwrap();
let tls_connector = native_tls::TlsConnector::builder()
.add_root_certificate(root_cert)
.build()
.unwrap();
let agent = ureq::AgentBuilder::new()
.tls_connector(tls_connector.into())
.build();
let req = agent.post("https://192.168.0.8:5000/")
.timeout(std::time::Duration::from_secs(1))
.set("Expect", "100-continue");
let res = req.send(string.as_bytes()).unwrap();
println!("res2: {:?}", res);
assert_eq!(res.status(), 200);
let body = res.into_string().unwrap();
assert_eq!("Hello, world!", body);
}
fn main() {
request();
}
#[test]
fn test_a() {
for i in 1..1000 {simultaneously run
println!("\nRun {i}\n");
request();
}
}
server
#!/usr/bin/env python3
from flask import Flask, request
from werkzeug import serving
from time import sleep
app = Flask(__name__)
@app.route('/', methods = ['POST'])
def a():
body = request.data
sleep(2)
return "Hello, world!"
if __name__=='__main__':
cert_chain_path = "Entity-chain.crt"
priv_key_path = "Entity.key"
ssl_ctx = (cert_chain_path, priv_key_path)
app.use_reloader = False
server = serving.make_server(
host="0.0.0.0",
port=5000,
app=app,
ssl_context=ssl_ctx)
server.serve_forever()
from ureq.
Related Issues (20)
- `impl From<http::request::Parts> for ureq::Request` HOT 2
- Peer misbehaved: `ResumptionOfferedWithVariedCipherSuite`
- Feature request: read `http_proxy` environment variable as proxy config HOT 1
- WebAssembly support HOT 4
- Respect `NO_PROXY` environment variable. HOT 3
- Power9 support HOT 2
- AgentBuilder should be clonable HOT 3
- Sometimes fails to retrieve a response when the server doesn't read the body HOT 9
- Export "cookie" crate
- Updating `http` was a breaking change HOT 3
- Replace httpbin.org in all examples and tests HOT 5
- Update rustls for RISCV64 support HOT 5
- Trust invalid certificate convenience function HOT 3
- Set local address to bind a specific interface HOT 2
- [Bug] In some case return empty "Content-Length" response header HOT 3
- Timeout not working when having packet losses HOT 1
- Support Multipart Forms HOT 1
- Timeout not always respected HOT 5
- Invalid transformation to http::Response<Vec<u8>> for non utf8 response bodies HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ureq.