Play Framework application bind address and port

I have recently begun experimenting with the Play Framework and I think it is great. Definitely something worth looking into. This post is based on my experience with Play 2.1.2, but I am convinced that it applies to 2.0.x versions as well (and quite possibly to older versions too). I am using an embeded Netty server that is a build in default server in Play Framework.
Play works just fine if you are satisfied with the defaults, but the alternative configuration can pose a challenge.
The default bind address is 0.0.0.0:9000 and it fine, but I needed it to change to meet the OpenShift's demands. I wanted to bind a Play application on one specific address along with a non standard port.
The configuration described in the Play's documentation works, but only from the Play's console and I needed to launch the application directly from the command line and that is where I got stuck for quite a while. And this is what I found out.



If you want your application to bind to a different port and address while launching it directly from a command line by a following command, you have to use a quotation marks to group all the parameters together.
This is how you start your application using defaults (0.0.0.0:9000).
$ play start
This is how you bind your application to the 8080 port (still all addresses).
$ play "start 8080"
And finally this is how you bind the application to a specific address and a port.
$ play "start -Dhttp.port=1234 -Dhttp.address=127.0.0.1" 
Please note that the quotation marks are vital. You don't need them when you are launching your application from the Play's console, but you have to use them from the command line. If you omit the quotation marks, everything after the first word (start in this case) is disregarded.

Comments

Popular posts from this blog

Ldap security for Jenkins CI

Automatic jsp recompile on Jboss AS 7

Simple EJB Arquillian test based on JUnit running on managed JBoss AS 7