Reputation: 23
Googling tomcat and websockets has revealed a number of pages on how to implement WebSockets in Tomcat, and in how to set up SSL/TLS in general, but it's not clear how to use both. In the SSL howto (http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html#Configuration), a connector is created for use with HTTPS. Does a similar connector exist for WSS, and if so, what exact string values do I give to the attributes?
Upvotes: 2
Views: 6320
Reputation: 4188
Basically WebSocket doesn't have its own port like normal Socket implementation. Rather it uses the same port of server on which it deployed (e.g. 8080 for tomcat). So, If you make necessary changes on Connector to allow https, your websocket will automatically use https port.
I recommend to use Tomcat version 7.0.42 or higher which is stable with WebSocket.
Also note that - You need to use 'wss' instead of 'ws' for WebSocket on client side (browser/mobile etc).
Upvotes: 2
Reputation: 20882
Any Tomcat <Connector>
(including those that support that HTTPS) can accept websocket requests. Essentially, any combination of connector (BIO, NIO, AJP, both secure and non-secure) and protocol (HTTP, Comet, websocket) is supported.
Upvotes: 4