Doing same with HTTPS results in an error, though:
>> require 'net-http2'
=> true
>> client = NetHttp2::Client.new("https://nghttp2.org")
=> #<NetHttp2::Client:0x0000000141d86048 @uri=#<URI::HTTPS https://nghttp2.org>, @connect_timeout=60, @ssl_context=#<OpenSSL::SSL::SSLContext:0x0000000141d855f8 @npn_protocols=["h2"], @npn_select_cb=#<Proc:0x0000000141d85198@[…]/net-http2-0.18.5/lib/net-http2/client.rb:190 (lambda)>>, @is_ssl=true, @mutex=#<Thread::Mutex:0x0000000141d84f40>, @h2=nil, @socket=nil, @socket_thread=nil, @first_data_sent=false, @streams={}>
>> response = client.call(:get, '/')
#<Thread:0x0000000141dbd160@[…]/net-http2-0.18.5/lib/net-http2/client.rb:112 run> terminated with exception (report_on_exception is true):
[…]/net-http2-0.18.5/lib/net-http2/client.rb:134:in `callback_or_raise': Socket was remotely closed (SocketError)
from […]/net-http2-0.18.5/lib/net-http2/client.rb:119:in `rescue in block (2 levels) in ensure_open'
from […]/net-http2-0.18.5/lib/net-http2/client.rb:113:in `block (2 levels) in ensure_open'
[…]/openssl/buffering.rb:182:in `sysread_nonblock': end of file reached (EOFError)
from […]/openssl/buffering.rb:182:in `read_nonblock'
from […]/net-http2-0.18.5/lib/net-http2/client.rb:145:in `block in socket_loop'
from […]/net-http2-0.18.5/lib/net-http2/client.rb:142:in `loop'
from […]/net-http2-0.18.5/lib/net-http2/client.rb:142:in `socket_loop'
from […]/net-http2-0.18.5/lib/net-http2/client.rb:114:in `block (2 levels) in ensure_open'
Traceback (most recent call last):
3: from […]/net-http2-0.18.5/lib/net-http2/client.rb:113:in `block (2 levels) in ensure_open'
2: from […]/net-http2-0.18.5/lib/net-http2/client.rb:119:in `rescue in block (2 levels) in ensure_open'
1: from […]/net-http2-0.18.5/lib/net-http2/client.rb:134:in `callback_or_raise'
SocketError (Socket was remotely closed)
Same happens for other servers (e.g. https://www.google.com, https://www.amazon.com), while they work fine using "curl --http2 -H 'User-Agent:' -H 'Accept:'" (-H options to remove default headers curl generates to ensure similarity).
I found that the servers actually respond with data, so I injected some debugging into the module at lib/net-http2/client.rb:146:
I've tried this getting same results on two different MacOS systems using the latest version and different rubies:
net-http2 (0.18.5)
http-2 (0.12.0)
ruby 3.3.5 / 2.6.8
I wonder what the issue could be here, as it looks the module is generally broken - which I can't imagine to be the case. 😄
Hi! I'm having weird basic issues using this library. When I do the same simple test as in the example it works:
Doing same with HTTPS results in an error, though:
Same happens for other servers (e.g. https://www.google.com, https://www.amazon.com), while they work fine using "curl --http2 -H 'User-Agent:' -H 'Accept:'" (-H options to remove default headers curl generates to ensure similarity).
I found that the servers actually respond with data, so I injected some debugging into the module at
lib/net-http2/client.rb:146
:which reveals that the servers seem to respond in HTTP/1 for some reason:
I've tried this getting same results on two different MacOS systems using the latest version and different rubies: net-http2 (0.18.5) http-2 (0.12.0) ruby 3.3.5 / 2.6.8
I wonder what the issue could be here, as it looks the module is generally broken - which I can't imagine to be the case. 😄
Thank you!