How to configure verticle to accept Secure websocket "wss" ?

1,403 views
Skip to first unread message

swapnil

unread,
Dec 27, 2012, 8:24:02 AM12/27/12
to ve...@googlegroups.com
Hi All,

Can you please tell me , how to configure verticle to accept Secure Websocket "wss" connection?

I am developing a app which will run on HTTPS, and app will make websocket calls to transmit some data. But as application will run on HTTPS, browser is not allowing to make ws connection , as its downgrade.

"The WebSocket connection starts its life with an HTTP or HTTPS handshake. When the page is accessed through HTTP, you can use WS or WSS (WebSocket secure: WS over TLS) . However, when your page is loaded through HTTPS, you can only use WSS - browsers don't allow to "downgrade" security."

My Server code is as given below, -

public class BridgeServer extends Verticle {

@Override
public void start() throws Exception {

HttpServer server = vertx.createHttpServer();

server.websocketHandler(new Handler<ServerWebSocket>() {

public void handle(final ServerWebSocket ws) {

ws.dataHandler(new Handler<Buffer>() {
public void handle(Buffer data) {
MeetingRoomController.getInstance().handleRequest(ws, data, vertx);
}
});

ws.endHandler(new Handler<Void>() {

@Override
public void handle(Void arg0) {
MeetingRoomController.getInstance().handleCloseConnectionRequest(ws, vertx);
}
});
}
}).requestHandler(new Handler<HttpServerRequest>() {
public void handle(HttpServerRequest req) {
}
}).listen(23456);

}
}

this server is ready to accept "ws" calls but not "wss" calls.

What I need to change in this code, so it will work ..

Thanks,
Swapnil

Randall Richard

unread,
Dec 27, 2012, 11:12:51 AM12/27/12
to ve...@googlegroups.com

You will need to configure your HttpServer to accept https.  Take a look at https://github.com/vert-x/vert.x/blob/master/vertx-examples/src/main/groovy/https/Server.groovy as an example.

You should then be able to use wss:// as your URI scheme.

-Randall


--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To view this discussion on the web, visit https://groups.google.com/d/msg/vertx/-/p3EZd1pmLCEJ.
To post to this group, send an email to ve...@googlegroups.com.
To unsubscribe from this group, send email to vertx+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/vertx?hl=en-GB.

swapnil....@gmail.com

unread,
Dec 28, 2012, 7:05:53 AM12/28/12
to ve...@googlegroups.com
Thanks Randall,

I will give you fair idea about my application.

Application is running in Tomcat Server which can be accessible only through HTTPS. Configuration done at apache server for HTTPS.

Now after opening application , some of application module talks with vertx server which is running outside of tomcat (its a separate instance). So in this case vertx server should only accept wss URI scheme. 

So can you please tell me what I need to do at vertx server to accept wss URI. 

and For this, I dont think I have to do 

 "HttpServer server = vertx.createHttpServer().setSSL(true).setKeyStorePath("server-keystore.jks")
       .setKeyStorePassword("wibble");" 

Becasue its for HTTPS not for WSS.

Please reply with your valuable comment.



Thanks and Regards,

Swapnil Bukkawar 

http://about.me/swapnil.bukkawar

Randall Richard

unread,
Dec 28, 2012, 12:20:37 PM12/28/12
to ve...@googlegroups.com
Swapnil, your setup is similar to how I use SockJS with HTTPS -- configuring a straight Websocket server should be pretty much the same approach.  Give the suggested HTTPS server set up a try and report back with any problems.

-Randall 
Reply all
Reply to author
Forward
0 new messages