Closed shalomb closed 4 years ago
Please could you try it with:
my $resp = await Cro::HTTP::Client.get('https://vial-http.appspot.com', :http<1.1>);
That was super quick @jnthn :)
Indeed, dropping down to HTTP 1.1 gets it working ..
$ perl6 ./cro-http-client.p6 'https://vial-http.appspot.com'
HTTP/1.1 200 OK
Content-Type: application/json
X-Cloud-Trace-Context: 2c39fa66ee4fb9a6fb3a36d04e93a683;o=1
Date: Thu, 26 Jul 2018 23:19:07 GMT
Server: Google Frontend
Content-Length: 19
Alt-Svc: quic=":443"; ma=2592000; v="44,43,39,35"
Connection: close
I shall try and gather a strace
too.
OK, that means it's something related to our HTTP/2.0 implementation. Alas, I don't have time to investigate right now (about to do some travel); @Altai-man perhaps you'd be able to reproduce/investigate this a bit sooner than I can?
In the meantime, I guess the :http<1.1>
workaround helps. If making many requests, then it can be more convenient to make an instance of Cro::HTTP::Client
and pass that option in the constructor, rather than having to pass it on each request.
Thanks @jnthn for the good work with cro .. :+1: Safe travels!!
@Altai-man - do let me know if I can assist with repros, additional information .. happy to help.
Hangs are not my strongest point, but let's try to resolve this.
It consists of two parts:
The connection is reset from server side, with PROTOCOL_ERROR for some reason.
[TRACE(anon 1)] Cro::HTTP2::FrameParser EMIT HTTP/2 Reset Stream Frame
Flags: 0
Stream ID: 1
Error Code: PROTOCOL_ERROR
While roughly the same request other http/2 implementations handle just fine.
Second part of issue: instead of proper propagation of error, it just awaits.
Second part is addressed in https://github.com/croservices/cro-http/commit/3fbb06b609f9f20fa3209c569c90cc2e3049389e As for first one, I suspect we are missing either some negotiation scheme or something like that, or we need to run our client implementation against spec debug tool to see if we're missing something.
Unknown string encoding: 'gb2312':
use Cro::HTTP::Client;
my $resp = await Cro::HTTP::Client.get('https://translate.google.cn', :http<1.1>);
say await $resp.body-text();
Output:
An operation first awaited:
in block <unit> at t1.pl6 line 32
Died with the exception:
Unknown string encoding: 'gb2312'
in block at /Applications/Rakudo/share/perl6/site/sources/557D6C932894CB1ADE0F83C0596851F9212C2A67 (Cro::MessageWithBody) line 51
Perl 6
perl6 -v
This is Rakudo Star version 2018.10 built on MoarVM version 2018.10
implementing Perl 6.c.
Cro::HTTP
zef info Cro::HTTP::Client
- Info for: Cro::HTTP::Client
- Identity: Cro::HTTP:ver<0.8.0>
- Recommended By: /Applications/Rakudo/share/perl6/site
- Installed: Yes
Description: Asynchronous HTTP, both client and server side. Includes HTTP/2.0 support.
License: Artistic-2.0
Source-url: https://github.com/croservices/cro-http.git
Provides: 47 modules
Depends: 11 items
Judging by https://github.com/perl-gsoc-2019/ideas/blob/master/perl6/GB2312-encoding-decoding.md it sounds like this encoding is not implemented at all on MoarVM level, so we really cannot help it from Cro level.
Please could you try it with:
my $resp = await Cro::HTTP::Client.get('https://vial-http.appspot.com', :http<1.1>);
I'm getting hanging and (max cpu) issue with your documentation example
my $client = Cro::HTTP::Client.new( headers => [ User-agent => 'Cro' ]); my $resp = await $client.get('https://www.perl6.org/');
It's fixed by adding :http<1.1>, so if this is the same thing and can't be fixed would suggest updating the documentation.
@MorayJ there was a known hang with HTTP/2 parser, it was fixed on master recently, but not yet released. Can you try it with fresh clone of cro-http repo? Using latest I can't reproduce the hang.
This is what I did, which I think is what you're wanting
git clone https://github.com/croservices/cro-http.git
cd cro-http/
zef install Cro::HTTP . --force-install
Still hanging...
If you are installing a distribution from the local directory, just zef install .
will be enough, possibly with --force-install
because you are installing a module with the same version as you might have installing.
I think I've tried it ok that way now. It doesn't use up all the cpu, but it still seems to be hanging for me
Just another voice -- I experienced the hanging and came here looking for a solution. The :http<1.1>
fixes it for me.
Following the documentation at https://cro.services/docs/reference/cro-http-client, I set out with a simple script to test some REST API interactions against https://vial-http.appspot.com/
However, this hangs almost indefinitely and the issue is reproducible every time.
Trying out a few different other URLs, I notice this seems to be correlated with HTTPS URLs (with the problem seemingly prevalent with those associated with google? but not always).