0
votes

This is a follow on question to my Heroku / Clojure problem here. As outlined in that thread, I was able to push my app to Heroku's master, and that deploys it.

But when I try to go to my app's URL, I get the below error. It's a bizarre port error, but I didn't think I had control over those details when deploying a Clojure app on Heroku. I think my setup's pretty straightforward. Is there anything I can do to address this error?

Procfile


    web: lein run -m http.handler

http.handler


    ...
    (def app      (handler/site main))

Error


    2011-12-31T04:10:02+00:00 app[web.1]: Listening for transport dt_socket at address: 41208
    2011-12-31T04:10:03+00:00 heroku[web.1]: Stopping process with SIGKILL    2011-12-31T04:10:03+00:00 heroku[web.1]: Error R11 (Bad bind) -> Process bound to port 41208, should be 55032 (see environment variable PORT)
    2011-12-31T04:10:04+00:00 heroku[web.1]: State changed from starting to crashed
    2011-12-31T04:10:05+00:00 heroku[web.1]: Process exited
    2011-12-31T04:20:08+00:00 heroku[web.1]: State changed from crashed to created    2011-12-31T04:20:08+00:00 heroku[web.1]: State changed from created to starting    2011-12-31T04:20:12+00:00 heroku[web.1]: Starting process with command `lein run -m http.handler`
    2011-12-31T04:20:16+00:00 app[web.1]: Listening for transport dt_socket at address: 49151    2011-12-31T04:20:16+00:00 heroku[web.1]: Error R11 (Bad bind) -> Process bound to port 49151, should be 39092 (see environment variable PORT)
    2011-12-31T04:20:16+00:00 heroku[web.1]: Stopping process with SIGKILL
    2011-12-31T04:20:17+00:00 heroku[web.1]: State changed from starting to crashed
    2011-12-31T04:20:18+00:00 heroku[web.1]: Process exited
    2011-12-31T04:31:13+00:00 heroku[web.1]: State changed from crashed to created
    2011-12-31T04:31:13+00:00 heroku[web.1]: State changed from created to starting
    2011-12-31T04:31:16+00:00 heroku[web.1]: Starting process with command `lein run -m http.handler`
    2011-12-31T04:31:20+00:00 app[web.1]: Listening for transport dt_socket at address: 44321
    2011-12-31T04:31:20+00:00 heroku[web.1]: Error R11 (Bad bind) -> Process bound to port 44321, should be 17211 (see environment variable PORT)
    2011-12-31T04:31:20+00:00 heroku[web.1]: Stopping process with SIGKILL
    2011-12-31T04:31:22+00:00 heroku[web.1]: State changed from starting to crashed
    2011-12-31T04:31:22+00:00 heroku[web.1]: Process exited
    2011-12-31T04:44:59+00:00 heroku[web.1]: State changed from crashed to created
    2011-12-31T04:44:59+00:00 heroku[web.1]: State changed from created to starting
    2011-12-31T04:45:02+00:00 heroku[web.1]: Starting process with command `lein run -m http.handler`
    2011-12-31T04:45:05+00:00 app[web.1]: Listening for transport dt_socket at address: 37500
    2011-12-31T04:45:06+00:00 heroku[web.1]: Error R11 (Bad bind) -> Process bound to port 37500, should be 14046 (see environment variable PORT)
    2011-12-31T04:45:06+00:00 heroku[web.1]: Stopping process with SIGKILL
    2011-12-31T04:45:07+00:00 heroku[web.1]: State changed from starting to crashed
    2011-12-31T04:45:07+00:00 heroku[web.1]: Process exited
    2011-12-31T04:49:22+00:00 heroku[router]: Error H10 (App crashed) -> GET bkeeping.herokuapp.com/ dyno= queue= wait= service= status=503 bytes=
    2011-12-31T04:49:31+00:00 heroku[router]: Error H10 (App crashed) -> GET bkeeping.herokuapp.com/favicon.ico dyno= queue= wait= service= status=503 bytes=

There seems to be a similar problem with Nodejs. But again, I don't think I have control of port assignments in a Compojure / Ring / Jetty deployment. Am I wrong? Would the behaviour change with Webnoir?

Thanks

2

2 Answers

3
votes

Make sure your handler binds to the correct port.

Heroku provides a port number through the environment variable $PORT so your code should have this somewhere after you define your app in your http.handler

(let [port (Integer/parseInt (System/getenv "PORT"))]
  (run-jetty app {:port port}))
0
votes

Although I got some really good hints, I wasn able to finally get past this. It turns out my project.clj had a defproject that included this JDPA config:


    :jvm-opts ["-agentlib:jdwp=transport=dt_socket,server=y,suspend=n"]

I should have noticed it earlier. But it just works locally, so I didn't think to question it. Hope this helps others who are having the same roadblock.