spdy-http2 / node-spdy

SPDY server on Node.js
2.81k stars 196 forks source link

Fallback to using specified protocol (if available) in secure mode #280

Closed anandsuresh closed 7 years ago

anandsuresh commented 7 years ago

On older versions of node with no ALPN support, socket.npnProtocol is returned as undefined, resulting in the activation of fallback mode. This commit allows for falling back to a user-defined protocol in case NPN/ALPN extensions aren't available.

indutny commented 7 years ago

When there are no NPN and no ALPN - fallback should be used. That's why we have fallback! 😉

anandsuresh commented 7 years ago

@indutny Have sent you an email with more details. Perhaps I'm not understanding the use-case correctly or have done a bad job at explaining the issue? ;)

anandsuresh commented 7 years ago

@indutny This patch is to address the case where a client with NPN extensions attempts to connect to a server with ALPN extensions. Since there is no way the client and server can successfully negotiate a protocol, this patch allows the developer to specify one. In the event, one isn't provided by the developer, then the Agent activates fallback. Does that make sense?

anandsuresh commented 7 years ago

@indutny Just confirmed the case described above with node v6.7.0. node-spdy selects the h2 protocol correctly, now that its running on a version of node that supports ALPN. But on node v4, it activates fallback because the client and server don't have a common extension to allow the selection of the application-level protocol.

indutny commented 7 years ago

I'm convinced now, sorry for not understanding it at first.

indutny commented 7 years ago

Just a few changes before this will be ready to land.

anandsuresh commented 7 years ago

Fixed as requested!

indutny commented 7 years ago

Landed in 74d8268, thank you! Would you care to open an issue for writing a test for this?