0

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 Answers 2

3

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}))
Sign up to request clarification or add additional context in comments.

3 Comments

This is definitely it, I had a similar issue which was promptly fixed by setting the port to (System/getenv "PORT") rather than one I had setup manually.
Thanks for the feedback on this. I modified my Compojure http.handler to pass in the PORT. But I'm still getting the same port error. I can throw up more code if need be. But my Procfile looks the same. And I'm pushing my custom branch to heroku with git push heroku <my-branch>:master.
I can't see the error with your code. Could you throw that project online, with the main handler and procfile? You can remove any other code, just leave a Hello World and I'd be happy to give it a shot.
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.