`lein run` on new app with http-kit does not work
Closed this issue · 4 comments
Hello, I recently bought the beta version of Web Development with Clojure, Third Edition, and I'm running into issues in the first chapter.
On my Mac, doing:
lein new luminus guestbook +h2 +http-kit && cd guestbook && lein run
gives me connection refused, when I try to connect to localhost:3000
. That is:
$ wget localhost:3000
Resolving localhost (localhost)... ::1, 127.0.0.1
Connecting to localhost (localhost)|::1|:3000... failed: Connection refused.
Connecting to localhost (localhost)|127.0.0.1|:3000... failed: Connection refused.
The odd thing is that the same command with +immutant
instead of +http-kit
works on the Mac, whereas both +http-kit
and +immutant
work as expected on my Linux machine. Is there a pre-requisite for http-kit
to work on a Mac?
I tried it both on JDK-8 and JDK-11 with the same effect. I'm running macOS Catalina v10.15.7 and Leiningen 2.9.4. I can't quite figure out what I've missed out. Any help on this would be greatly appreciated!
EDIT: just to confirm that http-kit
is the issue, if I swap [luminus-http-kit "0.1.9"]
with one of [luminus-immutant "0.2.5"]
, [luminus-undertow "0.1.7"]
and [luminus-aleph "0.1.6"]
, it all works as expected without having to change anything else.
EDIT2: I managed to grab a fresh Mac, and cannot replicate this. Something is still wrong with my machine, and if I could get some pointers on how to fix it, it would be great! However, this does not seem like a Luminus issue, so I'm closing it.
Hmm, not sure why that was happening here either. I'm not able to replicate it on my mac as well.
Hi Dmitri, I managed to get http-kit
to work on Babashka. I'll look into just http-kit
and luminus-http-kit
, and hopefully be able to pinpoint the problem. I'll try to open an appropriate issue in the right place.
Hi Dmitri (@yogthos), I found the issue, and I'm not sure if this is something you'd like a PR for.
The problem is in the environment variables. I've got the environment variable IP
set (by having export IP=$(ifconfig en0 | grep inet | awk '$1=="inet" {print $2}')
in my .bash_profile
).
So that this does not work:
(http/start
(-> env
(assoc :handler (handler/app))
(update :port #(or (-> env :options :port) %)))
but this does:
(http/start
(-> env
(assoc :handler (handler/app))
(update :port #(or (-> env :options :port) %))
(select-keys [:handler :host :port])))
and this does:
(http/start
(-> env
(assoc :handler (handler/app))
(update :port #(or (-> env :options :port) %))
(dissoc :ip)))
I'm sure this will be a rare issue, but I thought perhaps we could do another dissoc
here?
Ah I see, it might be better to do select-keys
in the template since there could be a valid reason to pass the :ip
key to http-kit.