Closed michalwski closed 6 years ago
Websocket handlers and protocol-handling are currently an undocumented feature, hence why protocols
is not documented. I plan to document it in a future release.
I do not think there should be a specific handler by default when the protocol is not recognized, the current behavior is fine, it just needs documentation.
I suggest you silence Dialyzer for now and I will try to add the documentation for this in Gun 1.3 next week. If I can't make it then I'll take some time after that to document the few experimental features we got into a Gun 1.4.
All right, thanks! Is there sth I can help you with regarding the issue? I'd really want to see this fixed in 1.3 and I may be able to spent some time on preparing a PR.
Feel free to extend ws_opts() and add the relevant documentation in the manual.
Currently the ws_opts type is defined in gun.erl:152
From what I understand and from what is in fact needed when using gun for WebSockets with
sec-websocket-protocol
specified, the type needs to also allowprotocols
key. See how I need to call thews_upgrade
in esl/escalus in order to successfully upgrade the connection.From what I understand, the
protocols
proplist is required because in gun_http:ws_handshake_protocol, gun will try to find the protocol on the list in case the server incudes thesec-websocket-protocol
header in its response.I'm wondering what's the correct way to fix the issue? The simplest would be to modify the
ws_opts
type. On the other hand, maybe gun could use the defaultgun_ws_h
in case there is no handler specified for the protocol? This handler works in my case perfectly.