socketry / async-http

MIT License
298 stars 45 forks source link

NoMethodError: undefined method `request_uri' for wss schema #20

Closed moskvin closed 5 years ago

moskvin commented 5 years ago

Can you help me to fix following crash:

5.71s: <Async::Task:0x3ff93d528c8c failed>
      |   NoMethodError: undefined method `request_uri' for #<URI::Generic wss://test.host>
      |   → /vendor/bundler/ruby/2.6.0/gems/async-http-0.40.3/lib/async/http/url_endpoint.rb:117 in `path'
      |     /vendor/bundler/ruby/2.6.0/gems/async-websocket-0.10.0/lib/async/websocket/client.rb:41 in `open'

Do I understand correctly, that now I have to use https:// instead of wss:// ?

ioquatix commented 5 years ago

Yes, because Ruby URI doesn't understand "wss". In fact, I don't know any part of the protocol that uses "wss" except that it's mandated (?) by browsers, but there is no technical reason why it should be the case, because WebSocket must by nature use HTTP initially and then issue upgrade: websocket request. In fact, it's even more confusing because for HTTP/2, it's definitely HTTP protocol. There is no actual "ws" or "wss" protocol, or even scheme, or connection, it's just HTTP until you upgrade the connection (HTTP/1) or issue CONNECT with :protocol: websocket (HTTP/2). The entire time it's still speaking HTTP. ¯\_(ツ)_/¯

ioquatix commented 5 years ago

Also there are a bunch of changes coming to support websockets via HTTP/1 and HTTP/2. It's still a work in progress though, but hopefully released this week.

moskvin commented 5 years ago

Thank you!

ioquatix commented 5 years ago

Okay the latest release is available, it supports both HTTP/1 and HTTP/2. The negotiation features still need some work but it's functional.