You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I connect to it via ws://... or wss://... in standalone mode (KTOR from main) it works perfectly. When I deploy my app as WAR in Tomcat 9.0.8 and let KTOR run via Servlet and try to connect to the same websocket either securely or unsecure it gives a 501 HTTP Status with no further information.
I turned on the tracing and found that the route works as expected:
Having looked more into this I now think that forwarding websocket from Tomcat to Ktor is simply not implemented.
In order to run Ktor in a servlet container the Servlet io.ktor.server.servlet.ServletApplicationEngine which is a io.ktor.server.servlet.KtorServlet creates the ApplicationEngine and forwards the normal HTTP Requests to it. However, Websocket in Servlet Containers works over a different API javax.websocket.* and require a declared ServerEndpoint that receives and processes the websocket message. As far as I can tell neither the Ktor Servlet nor the Ktor WebSockets feature provides a shim here and this is why this use case fails with 501 Not Implemented.
wulf0r
changed the title
Can't connect to KTOR WebSocket when running as WAR in Tomcat
Can't connect to Ktor WebSocket when running as WAR in Tomcat
Jun 3, 2020
KTOR 1.3.1 Server with WebSockets, Auth, Locations, Jackson, Servlet
In my application I defined a websocket route per the Websockets DSL:
When I connect to it via
ws://...
orwss://...
in standalone mode (KTOR from main) it works perfectly. When I deploy my app as WAR in Tomcat 9.0.8 and let KTOR run via Servlet and try to connect to the same websocket either securely or unsecure it gives a 501 HTTP Status with no further information.I turned on the tracing and found that the route works as expected:
the response I get is
I also tried to connect to a WebSocket that has no route defined and as expected I got a 404 error
The text was updated successfully, but these errors were encountered: