This is a cross post with
http://stackoverflow.com/questions/41007216/websocket-handshake-on-tomcat-returns-unexpected-response-code-500
:
I have a WebSocket application that registers the endpoint
programmatically, without the use of Annotations.
The relevant code is:
|ServerEndpointConfig.Configurator configurator =
(ServerEndpointConfig.Configurator)configuratorClass.newInstance();
ServerEndpointConfig serverEndpointConfig = ServerEndpointConfig.Builder
.create(endpointClass, endpointPath) .configurator(configurator)
.build(); ServerContainer serverContainer = (ServerContainer)app
.getServletContext()
.getAttribute("javax.websocket.server.ServerContainer");
serverContainer.addEndpoint(serverEndpointConfig); |
Everything works fine when I run it inside an IDE with an embedded Jetty
container, where the dependency is on tomcat-websocket and
tomcat-websocket-api libraries via Maven, but when I deploy it in Tomcat
(8.5.5), and then try to establish a WebSocket connection, I get the
following error in the browser's console:
WebSocket connection to 'ws://127.0.0.1:8080/echo' failed: Error
during WebSocket handshake: Unexpected response code: 500
I do not get any error or other information logged in the Catalina
output, and am not sure how to go about debugging this issue.
I need to configure the endpoint programmatically because much of the
information is not known at compile time, so please do not point me to
an Annotation solution.
Any help would be greatly appreciated, thanks!
--
Igal Sapir
Lucee Core Developer
Lucee.org <http://lucee.org/>