Skip to content
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

Review ClientUpgradeRequest exception handling #3705

Closed
sbordet opened this issue May 28, 2019 · 5 comments
Closed

Review ClientUpgradeRequest exception handling #3705

sbordet opened this issue May 28, 2019 · 5 comments
Assignees

Comments

@sbordet
Copy link
Contributor

sbordet commented May 28, 2019

Jetty 10.0.x's org.eclipse.jetty.websocket.core.client.ClientUpgradeRequest.onComplete() handles upgrade failures differently from 9.4.x.

In particular, java.net.ConnectionException should not be wrapped in an UpgradeException, so that client applications will know that the failure may be temporary (e.g. server restarting).

I would revert this logic to be the same as 9.4.x unless there are strong reasons for not to.

@joakime
Copy link
Contributor

joakime commented May 28, 2019

The example java.net.ConnectException is based on java.net.SocketException which is specifically excluded and not wrapped in an UpgradeException.

https://github.com/eclipse/jetty.project/blob/jetty-10.0.x/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/client/ClientUpgradeRequest.java#L226-L239

Same section on jetty-9.4.x btw (which has a shorter list of excluded exception types)

https://github.com/eclipse/jetty.project/blob/jetty-9.4.x/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/WebSocketUpgradeRequest.java#L510-L520

@sbordet
Copy link
Contributor Author

sbordet commented May 28, 2019

@joakime you pointed out that the logic is different, like I said.

Furthermore, in 9.4.x a ConnectException was notified to the WebSocket endpoint via a call to onError() (depending on whether the endpoint was implementing WebSocketListener or annotating methods) , while in 10.0.x this is not done, relying entirely on the future returned by connect().
I think this may be open to discussion, but I think the endpoint should be notified - it acts as a "callback" for WebSocket events and in this case an error trying to connect to the server.

@sbordet
Copy link
Contributor Author

sbordet commented May 29, 2019

@lachlan-roberts this issue is the last one that holds back CometD 6 and therefore a release of Jetty 10, so please give it higher priority.

Some thoughts: the FrameHandler is being created really late, and only when the upgrade is successful.
I think it should be created earlier because what it does (building the method handles to invoke the WebSocket endpoint) is necessary for both the case of a successful upgrade and the case of any failure (from not even able to connect to the server to a non 101 response).
I think this needs some refactoring to various components, to receive the 'FrameHandler` reference to invoke the error methods on it.

@gregw
Copy link
Contributor

gregw commented May 29, 2019

Note that I think the onOpen and onError callbacks should be the primary mechanism for communicating success or failure of a connect call. I think the connect methods returning futures could be deprecated if need be... or discouraged in some way.

@lachlan-roberts
Copy link
Contributor

Currently jetty-10.0.x uses onError quite differently to how it was used in jetty-9.4.x.

I believe in jetty-9.4.x onError can be called multiple times and you can even receive an onError after you have received an onClose.

In jetty-10.0.x onError is tied directly to onClose, such that if there is an error there is also a corresponding close. So if there was no onOpen notification you will not be getting an onError or onClose call.

lachlan-roberts added a commit to lachlan-roberts/jetty.project that referenced this issue May 31, 2019
…ilure

getFrameHandler on the ClientUpgradeRequest no longer takes
the upgrade response, the response must be set later if it is
required by the framehandler implementation

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
lachlan-roberts added a commit to lachlan-roberts/jetty.project that referenced this issue May 31, 2019
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
lachlan-roberts added a commit to lachlan-roberts/jetty.project that referenced this issue Jun 3, 2019
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
lachlan-roberts added a commit to lachlan-roberts/jetty.project that referenced this issue Jun 4, 2019
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
lachlan-roberts added a commit to lachlan-roberts/jetty.project that referenced this issue Jun 5, 2019
- sessionFutures for jetty and javax are now implemented using the
futureCoreSession which will occur after onOpen

- the request and response are set on the FrameHandler before the
upgrade

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
lachlan-roberts added a commit that referenced this issue Jun 5, 2019
* Issue #3705 - notify WebSocket framehandler on client upgrade failure

getFrameHandler on the ClientUpgradeRequest no longer takes
the upgrade response, the response must be set later if it is
required by the framehandler implementation

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>

* Issue #3705 - changes from review

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>

* Issue #3705 - throw if FrameHandler could not be created

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>

* wip

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>

* Issue #3705 - count down the onOpen latch in NetworkFuzzer

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>

* Issue #3705 - WebSocket Session CompletableFuture refactor

- sessionFutures for jetty and javax are now implemented using the
futureCoreSession which will occur after onOpen

- the request and response are set on the FrameHandler before the
upgrade

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
lachlan-roberts added a commit that referenced this issue Sep 16, 2019
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
lachlan-roberts added a commit that referenced this issue Sep 16, 2019
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants