-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
HttpClient crashes when using lantern VPN on Ubuntu. #37808
Comments
/cc @zichangg |
Status update: in secure_socket.dart, we got a null socket object.
I added some log to track why socket == null, it seems that after createProxyTunnel send CONNECT message, the connection is closed and socket is set to null. _HttpClient socket should be closed at here:
Is this closing action corrent? should it keep a connection fot http proxy? please advise, thanks. |
Thanks for posting! Let me assign myself first and take a look later. |
Hi @zichangg,
tinyproxy:
lantern:
I tracked the code that in http_parser.dart, _HttpParser._onData will process the response. And when received lanterns response, because of "Content-Length: 0", _HttpParser will close the socket, which will cause the above crash. bool _headersEnd() { currenttly, I add a _keepAlive flag to indicate that even content length == 0, it should not close the socket. and it works for me. if ((_transferLength == 0 && !_keepAlive) Next, I am going to check the definition of "Keep-Alive: timeout=58", check if it need to translate into more details. |
Thanks for the effort! But I'm not an expert on this area. The problem is parser does not handle this field correctly, considering both httpserver and httpclient both have a field called [idleTimeout]. Maybe RFC2616 can give more info on how to parse [keep-alive]. |
@mkustermann I saw you were the reviewer of original cl. Any thought? |
@zichangg The c6e632b you refer to seems only related to be more lenient when parsing the headers. I don't think parsing is the problem here. It seems that @sortie Could you take a look at this? |
Status update: I think at this point, I should check if it is a "CONNECT"'s response and return directly if success. Please check the patch atached. 0001-fix-crash-issue-when-HttpClient-using-lantern-proxy.patch.txt |
Is there a solution? |
@liamappelbe u are very good |
According to RFC 7231 4.3.6, A client MUST ignore any "Content-Length" or "Transfer-Encoding" header fields received in a successful response to CONNECT. Bug: #37808 Change-Id: I776f54b93807b4b7f9d9c9b9139728fa0415942a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/140564 Commit-Queue: Zichang Guo <zichangguo@google.com> Reviewed-by: Siva Annamalai <asiva@google.com> Reviewed-by: Jonas Termansen <sortie@google.com>
Closing because as far as I understand, 236dd99 fixes the issue. |
@sortie It does not seem to be resolved, I still have this problem in version 2.8.1. The tag of 236dd991e540e26db22473998cc5354051464bf1 contains version 2.8.1 |
@zichangg What do you think? |
I can confirm the problem does have. I'm able to have a repro locally. Work on the fix now. |
Not only exists with Ubuntu, this is a bug not caused by any platform, but the code bug of Http Client |
I've just started getting this issue in a Flutter project, due to an update to the Proxyman app on OSX. My Dart/Flutter details:
|
Due to a bunch of issues on null safety, the review process is quite slow recently. It probably needs another 1 or 2 days to land. Also thanks to @lixiangthinker for diagnosing the problem. |
If "CONNECT" is used in HttpClientRequest, it is supposed to create a tunnel and reuse the socket. The socket should remain open instead of being closed. Bug: #37808 Change-Id: Ic765bdc6fe4d3e21b3117e882b38e3abae15ceda Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148684 Commit-Queue: Zichang Guo <zichangguo@google.com> Reviewed-by: Jonas Termansen <sortie@google.com> Reviewed-by: Siva Annamalai <asiva@google.com>
still have this problem in Flutter 1.20.0-1.0.pre |
@lyf571321556 "dart" you were using was still build 2.9.0-16.0.dev. The fix went in 2.9.0-19.0.dev. |
dart --version
)Dart VM version: 2.5.0-dev.1.0 (Unknown timestamp) on "linux_x64"
Hi, Dart team,
I get an error when updating flutter sdk using flutter pub get. same issue as flutter/flutter#12301. I think the root cause may related to the dart:io package.
Here's my analyze:
`
import "dart:io";
void main() {
var google = "https://www.google.com/";
var client2 = HttpClient();
// same crash
// client2.findProxy = (uri) {
// return "PROXY 127.0.0.1:45653";
// };
// same crash
client2.findProxy = (url) {
return HttpClient.findProxyFromEnvironment(
url, environment: {"http_proxy": "127.0.0.1:45653", "https_proxy": "127.0.0.1:45653"});
};
// no respond.
// client2.findProxy = HttpClient.findProxyFromEnvironment;
// no respond.
// client2.findProxy = null;
client2.getUrl(
Uri.parse(google))
.then((HttpClientRequest request) {
print(request.headers);
return request.close();
}).then((HttpClientResponse response) {
// Process the response.
print(response.headers);
});
}
`
Unhandled exception: NoSuchMethodError: The setter 'readEventsEnabled=' was called on null. Receiver: null Tried calling: readEventsEnabled=false #0 _rootHandleUncaughtError.<anonymous closure> (dart:async/zone.dart:1112:29) #1 _microtaskLoop (dart:async/schedule_microtask.dart:41:21) #2 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5) #3 _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:116:13) #4 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:173:5)
I think this may related to my VPN environment settings. The following parameters are set automatically by Lantern VPN software. https://github.com/getlantern/lantern
`lixiang@lixiang-TM1701:~$ env | grep proxy
https_proxy=http://127.0.0.1:45653/
http_proxy=http://127.0.0.1:45653/
no_proxy=localhost,127.0.0.0/8,::1
`
curl https://www.google.com
`
package com.tony.builder;
import org.apache.http.HttpEntity;
import org.apache.http.HttpHost;
import org.apache.http.ParseException;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import java.io.IOException;
public class Main {
}
`
Any ideas or suggestion will be helpful, thanks.
@sgjesse https://github.com/sgjesse Maybe you have more ideas? thanks.
The text was updated successfully, but these errors were encountered: