Closed GenericJam closed 2 years ago
Also perhaps another bug. If I put http_opts: [version: 'HTTP/1.1']
in the connect options it returns an error.
%{
connect_timeout: 60000,
retry: 10,
retry_timeout: 300,
transport: :tls,
tls_opts: [
verify: :verify_peer,
cacertfile: CAStore.file_path(),
depth: 99,
server_name_indication: host_verify(),
reuse_sessions: false,
verify_fun: {&:ssl_verify_hostname.verify_fun/3, [check_hostname: host_verify()]}
],
http_opts: [version: 'HTTP/1.1'],
protocols: [:http]
}
** (MatchError) no match of right hand side value: {:error, {:options, {:http_opts, [version: 'HTTP/1.1']}}}
Using a map I get a similar error.
** (MatchError) no match of right hand side value: {:error, {:options, {:http, {:version, 'HTTP/1.1'}}}}
I can still put in other options such as keepalive
without an error.
1- Can you add a gun:await(ConnPid, undefined)
after await_up
and see if it sends the enable_connect_protocol
setting? I'm not seeing a problem in the Gun test suite.
2- Is 'HTTP/1.1'
in Elixir an atom? It must be an atom.
1 - Adding :gun.await(gun_pid, nil)
or :gun.await(gun_pid, :undefined)
after await_up
in the above code sample just times out with {:error, :timeout}
then continues the rest of the code as before.
2- Yes, problem solved with
http_opts: %{version: :"HTTP/1.1"}
Then it probably means that the HTTP/2 server doesn't enable Websocket because it is not possible to setup Websocket without receiving that setting. Do you receive the setting under HTTP/2 TCP? Or by TCP you meant HTTP/1.1? Because HTTP/1.1 there's no such requirement.
With TCP I was testing it against localhost and a heroku deployed echo server so a different one.
I tried the above sample with api.bitfinex.com
with gun:await/2
with similar results.
What made me realize HTTP 1.1 vs 2 was the issue was I picked apart some sample working JS code from their tutorial and it was requesting HTTP 1.1. Maybe both of their servers are configured wrong because if you don't specify it gives you HTTP 2.
Do you know of a site I could use that implements it properly I could test against?
I don't off-hand. Gun uses Cowboy for its test suites and Cowboy supports HTTP/2 over Websocket. Right now if you really need Websocket it is probably safer to connect via HTTP/1.1, unless if you know HTTP/2 is supported AND you need to do other requests concurrently.
I think there's no issue, closing then, thanks!
If I comment out
protocols: [:http]
then it fails with a400 Bad Request
.I had this working using
tcp
with gun 2.0 rc 2 but when I try withtls
it always fails.