How does one specify alternate http.port in Play 2.0?

2,230 views
Skip to first unread message

Brian Guan

unread,
Sep 8, 2011, 7:19:18 PM9/8/11
to play-fr...@googlegroups.com
(Sorry if this is a newbie NO-OP question...)

Upon hearing about the availability of Play 2.0 preview, I quickly pull it from github and started tinkling with it.

I was quickly stuck on trying to find where to specify alternate http.port in Play2.

The 1.x way is to specify it in conf/application.conf but it is unclear whether this is even possible yet in 2.0, eventhough there is an empty file conf/application.yml.

Searching thru Play2.0, I see:

~/Projects/Play20$ grep -r '9000' *

framework/play/src/main/scala/core/server/NettyServer.scala:    val channel = bootstrap.bind(new java.net.InetSocketAddress(9000))
framework/play/src/main/scala/core/server/NettyServer.scala:    Logger.log("Listening for HTTP on port 9000...")
framework/play/src/main/scala/api/libs/MimeTypes.scala:        aos=application/x-nokia-9000-communicator-add-on-software
Binary file framework/play/target/scala-2.9.0.final/classes/play/core/server/NettyServer.class matches
Binary file framework/play/target/scala-2.9.0.final/classes/play/api/libs/MimeTypes$.class matches
README.textile:In the Play console just type @run@, and the server will start on port 9000. Then go to "http://localhost:9000/":http://localhost:9000/ to see the application.
samples/kiki/public/websockets.js:websocket = new WebSocket("ws://localhost:9000/sockets/reversed-echo");

Looks like 9000 is hardcoded for the time being.  

I am sure the devs are going to do this properly, but I also don't see this in the buglist on lighthouse (https://play.lighthouseapp.com)... should I log one?



Excited about Play 2.0,
- Brian Guan

Ronald Chan

unread,
Nov 16, 2011, 5:15:57 PM11/16/11
to play-fr...@googlegroups.com
Hi,

I know this is a couple months old but the issue still seems to be there. I'm trying to run the sample zentasks for Java on the "edge" play20 on git.

I'm running Mac OSX and (not sure why) I get the following:
[error] org.jboss.netty.channel.ChannelException: Failed to bind to: 0.0.0.0/0.0.0.0:9000

Play last gives me this:
[debug] 
[debug] Initial source changes: 
[debug] removed:Set()
[debug] added: Set()
[debug] modified: Set()
[debug] Removed products: Set()
[debug] Modified external sources: Set()
[debug] Modified binary dependencies: Set()
[debug] Initial directly invalidated sources: Set()
[debug] 
[debug] Sources indirectly invalidated by:
[debug] product: Set()
[debug] binary dep: Set()
[debug] external source: Set()
[debug] Initially invalidated: Set()
[debug] Copy resource mappings: 
[debug]

In any case, I tried to set http.port=8080 in application.conf but it still complains about unable to bind to 9000.

I would like the ability to change this in order to actually try the beta out as I normally use port 9000 for XDebug with PHP development. (Though in this case I don't believe it is the issue as I've shut off everything and netstat does not show 9000 as being in used.)

Guillaume Bort

unread,
Nov 16, 2011, 5:20:00 PM11/16/11
to play-fr...@googlegroups.com
Currently you can't change the http port. At least for the 'run'
command. If you are using 'start', it will read the port number from
the PORT environment variable. Of course we will fix that in the
future releases.

> --
> You received this message because you are subscribed to the Google Groups
> "play-framework" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/play-framework/-/vuUko6V8otEJ.
> To post to this group, send email to play-fr...@googlegroups.com.
> To unsubscribe from this group, send email to
> play-framewor...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/play-framework?hl=en.
>

--
Guillaume Bort

Ronald Chan

unread,
Nov 16, 2011, 5:24:26 PM11/16/11
to play-fr...@googlegroups.com
Thanks for the update.

laguiz

unread,
Feb 29, 2012, 3:33:25 PM2/29/12
to play-fr...@googlegroups.com
Any news on this?

> To post to this group, send email to play-framework@googlegroups.com.


> To unsubscribe from this group, send email to


> For more options, visit this group at
> http://groups.google.com/group/play-framework?hl=en.
>

--
Guillaume Bort

peter hausel

unread,
Feb 29, 2012, 4:24:12 PM2/29/12
to play-fr...@googlegroups.com
play "run 9015" 

or 

$ play
[myapp] $ run 9015

laguiz

unread,
Feb 29, 2012, 5:21:46 PM2/29/12
to play-fr...@googlegroups.com
Great! Thank you.

Ed Ropple

unread,
May 20, 2012, 7:45:14 PM5/20/12
to play-fr...@googlegroups.com
Is there a way to define this in a configuration file? I'm building multiple interacting applications and want to permanently host them on separate ports (for development purposes); having to manually manage ports for this sort of thing is a little silly. :)

-Ed

biesior

unread,
May 21, 2012, 1:52:48 PM5/21/12
to play-fr...@googlegroups.com
I didn't find such, however in such case I always create small shell script running the Peter's command. It works.


W dniu poniedziałek, 21 maja 2012 01:45:14 UTC+2 użytkownik Ed Ropple napisał:
Is there a way to define this in a configuration file? I'm building multiple interacting applications and want to permanently host them on separate ports (for development purposes); having to manually manage ports for this sort of thing is a little silly. :)

Edward Ropple

unread,
May 21, 2012, 2:15:49 PM5/21/12
to play-fr...@googlegroups.com
Sure, and that's what I ended up doing for now, but while that may be comfortable/usable for solo developers, I don't think that that scales when you have multiple developers working on a project in multiple environments where their particular settings may need to differ. :-(

-Ed

--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To view this discussion on the web visit https://groups.google.com/d/msg/play-framework/-/7Fk5GPBNVrgJ.

To post to this group, send email to play-fr...@googlegroups.com.
To unsubscribe from this group, send email to play-framewor...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.



--

Ed Ropple
http://edropple.com

biesior

unread,
May 21, 2012, 3:05:12 PM5/21/12
to play-fr...@googlegroups.com
Be more optimistic :)

From my team experience:
All you need is to create sample script (ie run-app.sample) and commit it to your version control system (VCS), also create real run script called run-app  and make sure it's ignored by VCS. Then, each developer can copy  run-app.sample content and paste to his own run-app and change the settings if required. Each of you can run/start application with simple call of ./run-app and still each of you can add custom parameters to run script.

What's more: if it was possible to declare port in application.conf, it was harder to change http.port per developer.

Finally, using custom shell scripts, you can ensure that every developer can also include his custom parameters or even whole configuration file as described in http://www.playframework.org/documentation/2.0.1/ProductionConfiguration

hope it's helpfull, grettings, biesior


W dniu poniedziałek, 21 maja 2012 20:15:49 UTC+2 użytkownik Ed Ropple napisał:
Sure, and that's what I ended up doing for now, but while that may be comfortable/usable for solo developers, I don't think that that scales when you have multiple developers working on a project in multiple environments where their particular settings may need to differ. :-(

-Ed

Edward Ropple

unread,
May 21, 2012, 5:32:36 PM5/21/12
to play-fr...@googlegroups.com
Hey - I appreciate the suggestion, but  your suggestion is exactly what I don't want to do--it's too ad-hoc for my liking. In my preferred workflow, all configuration data needs to be versioned, just like code; as far as I'm concerned, if it's not in a git repo, it full-stop doesn't exist. What this boils down to, for me, to is not wanting to have to maintain two separate methods of system configuration just to do what's kind of basic behavior in other environments. 

It's made a little more complex because there are currently 3 and eventually 5 different Play applications in the solution I'm building, and they're all going to need per-developer settings. Having to maintain a ton of different configuration data (or, y'know, five different shell scripts, each with different default parameters--ugh) is already going to be a bear - I hope it's understandable that I wouldn't want to add more troubles to my plate. =) This is a tangent, but it's related as I've been trying to think of a good way to do it so I can push it back upstream, but no luck so far. Maybe an optional setting of some flavor would be nice - a way to namespace changes for one specific Play application in a more comprehensive file? 

(For example, project "lander" might look to get its database information from "lander.db.default.*" instead of just "db.default.*". Have to think about that one some more.)

BTW - it's also not actually more difficult to change http.port if it's in application.conf because you can import application.conf into other configuration files. (Have your production settings in the default file, override in the per-system file.) I'm already familiar with -Dconfig.resource and friends, and that's actually exactly why I'd like to have http.port configurable in there. =)

Thanks, though!

-Ed

--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To view this discussion on the web visit https://groups.google.com/d/msg/play-framework/-/t2i59_gx8JMJ.

To post to this group, send email to play-fr...@googlegroups.com.
To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.

Jxtps

unread,
May 21, 2012, 6:22:25 PM5/21/12
to play-fr...@googlegroups.com
This doesn't work on Windows:
 
C:\work\play_project>play2 "run 9011"
9011"" was unexpected at this time.

Kevin Bosman

unread,
May 22, 2012, 3:08:12 AM5/22/12
to play-fr...@googlegroups.com
> This doesn't work on Windows:
>
> C:\work\play_project>play2 "run 9011"
> 9011"" was unexpected at this time.

This has been fixed on trunk.

George Finklang

unread,
Mar 27, 2014, 7:23:41 PM3/27/14
to play-fr...@googlegroups.com

I'm running into the same issue now - many different play applications, want to disambiguate ports in a portable way - so each application having their own port defined in conf files is the best way to go - this way no extra scripts need to be built/maintained, everything works through the play console/play startup script.

Ed, did you find a resolution for this?  Is there a way to read http.port from configuration?
Reply all
Reply to author
Forward
0 new messages