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
No WebSocket onConnect event with Jetty 9.4.6 #1800
Comments
Thanks for filing this here. Can you capture the |
Here are the traces with dumpAfterStart
|
I checked with 9.4.5 and the problem is already there. |
There's no is |
(Hopefully) unrelated, but ... You might want to remove the irrelevant jars in your WEB-INF
Those shouldn't be there (they conflict with server classes) Take look at junit + mockito + hamcrest too (those almost never show up in a production webapp) |
no, rvec_manager_de24a2f1 is an optional servlet I don't have on this install. When I force the loading of my websocket servlets in web.xml
I get these logs
|
I see them in your dump now.
With them loaded this way, do they work? |
I will check the libraries you pointed out but I know that I need at least those because I do some tricky (or nasty) forwarding on server side.
|
The servlets are loaded OK, I see the call to configure() in the debugger. But the problem then is that I never get the onConnect() call that I expect (@OnWebSocketConnect annotation). |
What client are you using? I'd like to try to reproduce this. |
I'm using Chrome Version 56.0.2924.87 (64-bit) on Linux I just tried on firefox 51.0.1 (64-bit) and it is the same problem |
Is the connection secured? (https/ssl) |
SSL is activated but not forced. I can install wireshark but I'm not very comfortable with the tool. |
OK. Lets see if I can whip up a small test project, see if you can replicate on it. |
Here's a sample project using native jetty websockets on the server side, with a webapp, using the WebSocketServlet. https://github.com/jetty-project/jetty-websocket-example I've tested this in the following ways: OS:
Jetty Server Versions:
Browsers:
It works for me in all of these combinations. Follow the readme on how to build / test with it. |
i Joakim So it's not a bug but some configuration that worked in 9.3 that does not work anymore in 9.4. I will try to alter your example to make it as close as possible from our usecase (web.xml, jetty-web.xml, Application... ). |
When I add a simple web.xml
... it breaks the websockets and I get 404 errors
|
When I declare explicitely the servlets in the web.xml it works.
|
I think I also have a problem with my WebSocket servlet being bound to a path not ending with slash (/sockets/scripts/ vs /sockets/scripts) I'm still investigating. |
I confirm, the problem was due to the fact my binding missed trailing slash. When I add the trailing slash (in addition to the explicit loading of the servlets) it works. Although I cannot reproduce the trailing-slash problem on your tiny example.
|
To conclude, I have two questions:
... and thank you very much for your help :-) |
Your descriptor declaration is invalid. <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> Annotation scanning is not available in Servlet 2.5, that's why your annotation scanning isn't present. |
The trailing slash question is interesting. I updated that |
Added an appropriate (webapp 3.1) No change in behavior, still behaves as expected. Going to try a few more changes to fit with your webapp ... a named |
New commit jetty-project/jetty-websocket-webapp-example@e42dfd7 Using No difference in behavior seen. Perhaps we need to crank up the DEBUG logging in your project to see what's going on. |
Hi Joakim, What you tells me is that the web.xml header I was using was wrong from the beginning but Jetty 9.3 was kind enough to do the annotation scanning anyway. I will try to confirm latter today and investigate the trailing slash a bit more. |
I confirm that using 3.1 header fix the detection of the servlets based on the annotations. |
@mdussere the statement earlier about the trailing slash is still interesting to me. If you have a way to modify that jetty-websocket-example to cause that trailing slash issue, please file an issue here. Thanks. |
Hi Joakim, I could not reproduce the problem with jetty-websocket-example while I was running on the very same Jetty I'm using for our application. Thanks for your time |
I had the same issue with Java Spark when they updated the Jetty dependency from 9.3 to 9.4. |
My websocket servlet does not work on Jetty 9.4.6.v20170531 although it works perfectly with version 9.3.2.v20150730.
My code looks like this:
and
When trying to access my socket, I get a 404 error. On server side, the configure is never called.
I tried to force the loading of the servlet by adding it to web.xml
Then the servet is loaded, configure function is called. When trying to open the socket, I don't get any error but the onConnect error is never called.
So far I have reverted to using Jetty 9.3.2, but it's not satisfying.
Any Idea ?
PS:
I already opened a question on stackoverflow
https://stackoverflow.com/questions/46097745/websocket-not-working-on-jetty-9-4
The text was updated successfully, but these errors were encountered: