WebSocket connection/debugging issues

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

WebSocket connection/debugging issues

Meggyesi, Zalán
Hi,

I'm running a small-ish Ninja app under Java 11 using the latest Jetty, and I'm running into trouble setting up a WebSocket connection, but I'm quite stuck on how to debug it.

The app runs behind an Nginx reverse proxy, which adds back the Connection: upgrade and Upgrade: websocket headers that would normally be stripped out, but it's as if Jetty itself removed these before the connection is passed to the application, because when I print the headers on the incoming connection, the Upgrade header is missing, and so the application doesn't know what to do with it, resulting in an eventual failed WS handshake. Needless to say, this all happens with the websockets module enabled in the installation.

I considered making a bug report, but I have zero evidence to back up my claim of Jetty mishandling WS connections. Is there a debug or verbose logging mode for Jetty itself, that could capture information as the connection is being handled - that way I could at least find out if I'm misconfiguring something.

Thanks in advance!

Best,
Zalan Meggyesi

_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: WebSocket connection/debugging issues

Joakim Erdfelt-8
Need to know more details.

When you enable the `websocket` module on `jetty-home`/`jetty-base` a few things happen.

1. The websocket JARs for the various APIs become available on the Server classpath.
2. The websocket ServletContainerInitializers kick in to initialize various things within the javax.servlet.ServletContext of your running webapp (via use of a WebAppContext).

In the case of `javax.websocket.server` the discovered @ServerEndpoint annotated classes are deployed (only with a WebAppContext).

There's nothing in your question that indicates if this is a websocket server issue? or a websocket client issue?
Also, you don't indicate which API you are using. (the jetty native websocket API, or the javax.websocket API)

If you are using websocket on server, put a breakpoint in WebSocketServlet or WebSocketUpgradeFilter to see what's happening there (depends on what API and technique for deployment you are using).

The tests for `isUpgradeRequest` is a good place to start debugging your behaviors.

See:


If the incoming request doesn't have the `Connection: upgrade` or `Upgrade: websocket` then one of two things is happening.

1. The client didn't send it
2. or Something is stripping out those headers

As for that "something is stripping out those headers" part, that could be a servlet Filter on your server side, it could be a Rewrite Rule that's stripping out on your server side, or something in front of Jetty is stripping them out.
A quick look through the code, there's nothing built into (or ships with) Jetty that will strip out those headers.

Joakim Erdfelt / [hidden email]


On Tue, Nov 20, 2018 at 12:17 PM Meggyesi, Zalán <[hidden email]> wrote:
Hi,

I'm running a small-ish Ninja app under Java 11 using the latest Jetty, and I'm running into trouble setting up a WebSocket connection, but I'm quite stuck on how to debug it.

The app runs behind an Nginx reverse proxy, which adds back the Connection: upgrade and Upgrade: websocket headers that would normally be stripped out, but it's as if Jetty itself removed these before the connection is passed to the application, because when I print the headers on the incoming connection, the Upgrade header is missing, and so the application doesn't know what to do with it, resulting in an eventual failed WS handshake. Needless to say, this all happens with the websockets module enabled in the installation.

I considered making a bug report, but I have zero evidence to back up my claim of Jetty mishandling WS connections. Is there a debug or verbose logging mode for Jetty itself, that could capture information as the connection is being handled - that way I could at least find out if I'm misconfiguring something.

Thanks in advance!

Best,
Zalan Meggyesi
_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users

_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users