{"action":"created","issue":{"url":"https://api.github.com/repos/actix/actix-web/issues/212","repository_url":"https://api.github.com/repos/actix/actix-web","labels_url":"https://api.github.com/repos/actix/actix-web/issues/212/labels{/name}","comments_url":"https://api.github.com/repos/actix/actix-web/issues/212/comments","events_url":"https://api.github.com/repos/actix/actix-web/issues/212/events","html_url":"https://github.com/actix/actix-web/issues/212","id":321010107,"number":212,"title":"Connection pool using client::get(uri).with_connector(...) is not respecting keep-alive","user":{"login":"parasyte","id":456942,"avatar_url":"https://avatars0.githubusercontent.com/u/456942?v=4","gravatar_id":"","url":"https://api.github.com/users/parasyte","html_url":"https://github.com/parasyte","followers_url":"https://api.github.com/users/parasyte/followers","following_url":"https://api.github.com/users/parasyte/following{/other_user}","gists_url":"https://api.github.com/users/parasyte/gists{/gist_id}","starred_url":"https://api.github.com/users/parasyte/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/parasyte/subscriptions","organizations_url":"https://api.github.com/users/parasyte/orgs","repos_url":"https://api.github.com/users/parasyte/repos","events_url":"https://api.github.com/users/parasyte/events{/privacy}","received_events_url":"https://api.github.com/users/parasyte/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-05-08T01:16:16Z","updated_at":"2018-05-08T01:28:09Z","closed_at":null,"author_association":"NONE","body":"I hacked together a quick proxy which is very similar to the [proxy example](https://github.com/actix/examples/blob/master/http-proxy/src/main.rs), except I'm using `ClientRequestBuilder.with_connector()` trying to utilize the built-in connection pooling.\r\n\r\n```rust\r\n#![feature(proc_macro, generators)]\r\n\r\nextern crate actix;\r\nextern crate actix_web;\r\nextern crate futures_await as futures;\r\n\r\nuse actix::{Actor, Addr, Unsync};\r\nuse actix_web::{client, server, App, Path, State};\r\nuse actix_web::http::Method;\r\nuse futures::prelude::*;\r\n\r\nstruct AppState {\r\n    conn: Addr<Unsync, client::ClientConnector>,\r\n}\r\n\r\n#[async(boxed)]\r\nfn index(info: Path<(u32, String)>, state: State<AppState>) -> Result<String, actix_web::error::Error> {\r\n    let uri = format!(\"http://127.0.0.1:8081/{}/{}/index.html\", info.0, info.1);\r\n\r\n    let resp = await!(client::get(uri)\r\n        .with_connector(state.conn.clone())\r\n        .no_default_headers()\r\n        .upgrade()\r\n        .finish()?\r\n        .send()\r\n    )?;\r\n\r\n    let body = await!(resp.into_future())\r\n        .unwrap()\r\n        .0\r\n        .unwrap();\r\n\r\n    Ok(std::str::from_utf8(&body)?.to_owned())\r\n}\r\n\r\nfn main() {\r\n    let addr = \"127.0.0.1:8080\";\r\n    println!(\"Listening on http://{}\", addr);\r\n\r\n    server::new(|| {\r\n        let conn: Addr<Unsync, _> = client::ClientConnector::default().start();\r\n        App::with_state(AppState{conn})\r\n            .resource(\"/{id}/{name}/index.html\", |r| r.method(Method::GET).with2(index))\r\n    }).bind(addr)\r\n        .unwrap()\r\n        .run();\r\n}\r\n```\r\n\r\nThe proxy functionality works (using the [basic hello-world example](https://github.com/actix/actix-web#example) as an upstream on port 8081), but keep-alive is not working, as you can see from tcpdump:\r\n\r\n```\r\ntcpdump: verbose output suppressed, use -v or -vv for full protocol decode\r\nlistening on lo0, link-type NULL (BSD loopback), capture size 262144 bytes\r\n18:05:42.542170 IP 127.0.0.1.58422 > 127.0.0.1.8080: Flags [S], seq 1194112351, win 65535, options [mss 16344,nop,wscale 5,nop,nop,TS val 1218386738 ecr 0,sackOK,eol], length 0\r\n18:05:42.542279 IP 127.0.0.1.8080 > 127.0.0.1.58422: Flags [S.], seq 3083285766, ack 1194112352, win 65535, options [mss 16344,nop,wscale 5,nop,nop,TS val 1218386738 ecr 1218386738,sackOK,eol], length 0\r\n18:05:42.542301 IP 127.0.0.1.58422 > 127.0.0.1.8080: Flags [.], ack 1, win 12759, options [nop,nop,TS val 1218386738 ecr 1218386738], length 0\r\n18:05:42.542322 IP 127.0.0.1.8080 > 127.0.0.1.58422: Flags [.], ack 1, win 12759, options [nop,nop,TS val 1218386738 ecr 1218386738], length 0\r\n18:05:42.542350 IP 127.0.0.1.58422 > 127.0.0.1.8080: Flags [P.], seq 1:154, ack 1, win 12759, options [nop,nop,TS val 1218386738 ecr 1218386738], length 153: HTTP: GET /123/jay/index.html HTTP/1.1\r\n18:05:42.542367 IP 127.0.0.1.8080 > 127.0.0.1.58422: Flags [.], ack 154, win 12754, options [nop,nop,TS val 1218386738 ecr 1218386738], length 0\r\n18:05:42.542567 IP 127.0.0.1.58423 > 127.0.0.1.8081: Flags [S], seq 1266615293, win 65535, options [mss 16344,nop,wscale 5,nop,nop,TS val 1218386738 ecr 0,sackOK,eol], length 0\r\n18:05:42.542637 IP 127.0.0.1.8081 > 127.0.0.1.58423: Flags [S.], seq 2134870156, ack 1266615294, win 65535, options [mss 16344,nop,wscale 5,nop,nop,TS val 1218386738 ecr 1218386738,sackOK,eol], length 0\r\n18:05:42.542647 IP 127.0.0.1.58423 > 127.0.0.1.8081: Flags [.], ack 1, win 12759, options [nop,nop,TS val 1218386738 ecr 1218386738], length 0\r\n18:05:42.542658 IP 127.0.0.1.8081 > 127.0.0.1.58423: Flags [.], ack 1, win 12759, options [nop,nop,TS val 1218386738 ecr 1218386738], length 0\r\n18:05:42.542708 IP 127.0.0.1.58423 > 127.0.0.1.8081: Flags [P.], seq 1:91, ack 1, win 12759, options [nop,nop,TS val 1218386738 ecr 1218386738], length 90\r\n18:05:42.542726 IP 127.0.0.1.8081 > 127.0.0.1.58423: Flags [.], ack 91, win 12756, options [nop,nop,TS val 1218386738 ecr 1218386738], length 0\r\n18:05:42.542810 IP 127.0.0.1.8081 > 127.0.0.1.58423: Flags [P.], seq 1:135, ack 91, win 12756, options [nop,nop,TS val 1218386738 ecr 1218386738], length 134\r\n18:05:42.542827 IP 127.0.0.1.58423 > 127.0.0.1.8081: Flags [.], ack 135, win 12755, options [nop,nop,TS val 1218386738 ecr 1218386738], length 0\r\n18:05:42.542908 IP 127.0.0.1.8080 > 127.0.0.1.58422: Flags [P.], seq 1:135, ack 154, win 12754, options [nop,nop,TS val 1218386738 ecr 1218386738], length 134: HTTP: HTTP/1.1 200 OK\r\n18:05:42.542935 IP 127.0.0.1.58422 > 127.0.0.1.8080: Flags [.], ack 135, win 12755, options [nop,nop,TS val 1218386738 ecr 1218386738], length 0\r\n18:05:42.546016 IP 127.0.0.1.58422 > 127.0.0.1.8080: Flags [F.], seq 154, ack 135, win 12755, options [nop,nop,TS val 1218386741 ecr 1218386738], length 0\r\n18:05:42.546051 IP 127.0.0.1.8080 > 127.0.0.1.58422: Flags [.], ack 155, win 12754, options [nop,nop,TS val 1218386741 ecr 1218386741], length 0\r\n18:05:42.546107 IP 127.0.0.1.8080 > 127.0.0.1.58422: Flags [F.], seq 135, ack 155, win 12754, options [nop,nop,TS val 1218386741 ecr 1218386741], length 0\r\n18:05:42.546137 IP 127.0.0.1.58422 > 127.0.0.1.8080: Flags [.], ack 136, win 12755, options [nop,nop,TS val 1218386741 ecr 1218386741], length 0\r\n18:05:43.200008 IP 127.0.0.1.58423 > 127.0.0.1.8081: Flags [F.], seq 91, ack 135, win 12755, options [nop,nop,TS val 1218387384 ecr 1218386738], length 0\r\n18:05:43.200039 IP 127.0.0.1.8081 > 127.0.0.1.58423: Flags [.], ack 92, win 12756, options [nop,nop,TS val 1218387384 ecr 1218387384], length 0\r\n18:05:43.200085 IP 127.0.0.1.8081 > 127.0.0.1.58423: Flags [F.], seq 135, ack 92, win 12756, options [nop,nop,TS val 1218387385 ecr 1218387384], length 0\r\n18:05:43.200123 IP 127.0.0.1.58423 > 127.0.0.1.8081: Flags [.], ack 136, win 12755, options [nop,nop,TS val 1218387385 ecr 1218387385], length 0\r\n```\r\n\r\nI would expect the `FIN` packets to not be sent to port 8081 (timestamps 18:05:43.200008 and above) if keep-alive was working, and the sockets should be reused indefinitely. The `FIN` is also delayed from the last `ACK` packet at `18:05:42.542827` ... by about 650ms."},"comment":{"url":"https://api.github.com/repos/actix/actix-web/issues/comments/387255919","html_url":"https://github.com/actix/actix-web/issues/212#issuecomment-387255919","issue_url":"https://api.github.com/repos/actix/actix-web/issues/212","id":387255919,"user":{"login":"fafhrd91","id":598990,"avatar_url":"https://avatars2.githubusercontent.com/u/598990?v=4","gravatar_id":"","url":"https://api.github.com/users/fafhrd91","html_url":"https://github.com/fafhrd91","followers_url":"https://api.github.com/users/fafhrd91/followers","following_url":"https://api.github.com/users/fafhrd91/following{/other_user}","gists_url":"https://api.github.com/users/fafhrd91/gists{/gist_id}","starred_url":"https://api.github.com/users/fafhrd91/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fafhrd91/subscriptions","organizations_url":"https://api.github.com/users/fafhrd91/orgs","repos_url":"https://api.github.com/users/fafhrd91/repos","events_url":"https://api.github.com/users/fafhrd91/events{/privacy}","received_events_url":"https://api.github.com/users/fafhrd91/received_events","type":"User","site_admin":false},"created_at":"2018-05-08T01:28:09Z","updated_at":"2018-05-08T01:28:09Z","author_association":"OWNER","body":"what version of actix-web do you use?"}}
{"actor":{"display_login":"fafhrd91"}}