Reputation: 51
For a bit now I've just been running lein figwheel
to start up my application. I generated the project using the luminus template. However, recently when connecting to a database I found that lein figwheel
does not allow me to connect to database. I'm assuming this is because it does not initialize the app. Which is weird because it will reload my plain clj files with no problem.
However, if I just use lein run
then I have the database connection.
After poking around I reread the Luminus docs and it says that I need to run both. And this is where I am very confused. lein run
opens a port to 3000, and figwheel opens up a port to 3449. Like I said, the first lets me connect to the database and the other gives me autobuilding. Do I connect to both ports?
So what step am I missing to get both worlds?
Upvotes: 2
Views: 1697
Reputation: 373
Harley mentioned this in the comment to the other answer, but I wanted to vouch for it. First, run your server however you'd like (I launch from the repl, but you can also use lein run
). Then use your browser navigate to whatever port you choose to run on. Then run lein figwheel
in another terminal and it will connect.
Upvotes: 1
Reputation: 520
I too, have never done both at the same time. However, I have done them separately and the different ports handle different "services". Port 3000 is the http port. If you built this from a luminus template, then you are probably building a web site. So, connect to 3000 with your browser.
Port 3449 is the web socket port that figwheel uses to push changes to the browswer. So,you start up a command-line lein figwheel an it goes looking for your 3449 port to talk to the browser. Now mind you, this command-line is both a repl and a monitor program. As you make changes to the source, figwheel recompiles your changes and sends the to the page at 3449. You can also execute code from the repl by changing the namespace of the repl (i.e. in-ns).
So, two different ports, two different protocols. What does port 3000 return to the browser? Well, depending on your server, whatever page you tell it to. Whereas, the 3449 is whatever figwheel defaults it to.
The real question is how to get figwheel to connect up to an existing page in a browser, not started by figwheel. I thought I had seen where someone had a JavaScript function that you embedded in your page and it talked/listened to figwheel.
Upvotes: 0