-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to handle missing extensions? #340
Comments
I would like to think that what is declared in your annotations is unconnected to what is available on the container. So declaring, for example, "permessage-deflate" means you would like to use it, but not mandate it's usage. For a Client Endpoint it offers that extension on the handshake only if the container supports it. For a Server Endpoint it negotiates that extension on the handshake only if the container supports it AND the client offered it on the handshake. |
Hmm. The extension registry only has two entries. Extensions haven't really taken off the way they might have done. Not really the topic of this issue but in terms of context I don't think the number of extensions justifies extending the WebSocket API to provide a standard API for extension implementations. I would argue that extensions are inherently optional. The WebSocket handshake includes the possibility that no extensions will be agreed. If an endpoint wants to require an extension they can intercept the handshake, examine the agreed extensions and cancel the connection if they don't like what they see. Extensions cannot currently be defined in My current thinking is that we make the following additions to the Jakarta WebSocket specification:
Assuming there is consensus for the above or something like it, I think updating some of the existing tests in the TCK is going to be tricky. |
Extensions have a few different view points with slightly different behavior. Client From a Client Endpoint point of view.
For the list of extensions available on the container, some new APIs to interrogate the list of registered / available extensions by name would be enough. For the client handshake request, it needs to have the ability to include a list extension configurations (not just names, but extensions with configuration parameters). We also need the client side to pay attention to the handshake response from the server. The "forbidden extension" behavior of a client endpoint would be a declaration by that endpoint to never offer a specific extension on the handshake request, even if the container supports it, even if the container level configuration says to offer it. Server From a Server Endpoint point of view it needs to know.
For the list of extensions available on the container, some new APIs to interrogate the list of registered / available extensions by name would be enough. For the server handshake request, it needs a variety of behaviors.
Protocol From a protocol point of view, the client extensions offer can include multiple entries for a single named extension, but with different configurations. |
Coming back to this as it is an open bug I'd like to try and close for 2.1. While I agree with @joakime's view of the complete set of required functionality, I think the very small number of extensions - really just I am currently thinking along these lines:
How to install support for an extension for both the client and the server would be container specific. I can put together a PR for this but I wanted to gather some feedback before I did so. |
Jetty has multiple extensions available btw.
Jetty dropped The autobahn websocket library (used for the official websocket support TCK) also supports ...
|
If you look around, you'll also find the following PMCE implementations already present in various websocket libraries.
|
Thanks, I wasn't aware of that. Tomcat hasn't had any requests (that I recall) to implement any of those. I'm not sure to what extent this complicates matters. My reading of RFC 7692 is that the server should accept the first PMCE that it can support and ignore the others. If that is extended to all compression extensions then I think my proposal could still work. And there remains the option to customize I guess the question is does adding something alone the lines of my proposal meet enough use cases to make it worth adding to the 2.1 spec? Additional configuration such as extensions that should always be offered regardless of what is configured for the endpoint would remain container specific. |
Any objections to proceeding along the lines I set out on 2021-10-07, a different approach or would we prefer to drop this issue? |
@markt-asf there are many messages on here from 2021-10-07, are you referring to proposal with the following ?
|
Yes |
Mostly correct.
👍 but this check is only performed by-name (the configuration parameters are not considered for this step)
I don't see the value of this in an Annotation.
The first part reads poorly, or can be interpreted to mean things we don't want it to mean. The server side extensions can be viewed as a map of Extension name to Extension parameters. Replace "Configuration of acceptable ranges and/or combinations of parameters is container specific." with We have a few things to think about here.
If the server side receives an extension configuration during handshake stage the that is not well formed, then the implementation MUST fail the connection per https://datatracker.ietf.org/doc/html/rfc6455#section-9.1
Sure, but only via the name of the extension, parameters in a configuration are not considered for this union. |
Also, when it comes to multiple configurations of the same extension, this is controlled by the extension. Now that I think about it, the Extension developers will need to know prior Extensions in the negotiation step. |
I was just paraphrasing. We can reference the RFC in the updated spec/Javadoc langauge.
Having looked at it again, I don't see any value either. I'll drop this.
Will do.
Happy with If the configuration requested by the client isn't supported by the server then the extension is not used unless the extension specifies different behaviour. If the client requires a configuration the server doesn't support then the client can fail the connection during
Ack. I think I have enough to draft a PR. I'll try and work on that today. |
The process of negotiating handshakes is clearly defined in section 3.1.3
What isn't discussed is what happens if
ClientEndpointConfig#getExtensions()
returns one or more extensions that the client side code does not recognise. An equivalent question applies toServerEndpointConfig#getExtensions()
.The TCK currently assumes that if the
ClientEndpointConfig
orServerEndpointConfig
declares an extension, it will be supported. The TCK then defines 3 random extensions and assumes both the client and the server will ignore the fact they don't recognise the extensions (since they can't possibly support them).Assuming that an unknown extension will be ignored could be problematic. If a genuine extension is declared by both the client and server and those endpoints are deployed in an environment where only one side recognises the extension it is likely that attempts to use the endpoints will fail as one endpoint tries to use an extension the other has declared support for but doesn't actually understand.
I'm currently thinking through what a fix for this might look like. I suspect it will have to wait for Jakarta EE 10 but maybe not.
The text was updated successfully, but these errors were encountered: