Closed kidpollo closed 5 years ago
Hmm, how do you exactly set :agent-host
? It seems to me that you are doing it at a wrong place because the message Dirac Agent is not listening at ...
should mention effective agent URL.
Agent host configuration should be part of Dirac Runtime configuration: https://github.com/binaryage/dirac/blob/master/docs/configuration.md#dirac-runtime---page-specific-configuration
Also please note that you will have to instruct Dirac nREPL middleware (which is running inside your VM) how to connect to your Browser (running outside the VM) for javascript evaluations. There must be a proper host pointing to the host machine as seen from inside the VM.
Please see https://github.com/binaryage/dirac/blob/master/docs/about-repls.md#executing-clojurescript conceptual overview how this works.
Let me describe what I want to do. I am setting up a brand new app with Clojure CLI tools. The way I do dev in my computer is I run a VM with archlinux where I run and edit code through the terminal or a remote x session. That is why when I run my browser I hit the VM IP and it seems to work fine with figwheel when I set the :websocket-host :server-hostname
in the config.
Then I tried to setup dirac and this is roughly what I ended up with:
This is the command and output I am attempting to run my figwheel build with
env DIRAC_NREPL/WEASEL_REPL/HOST="192.168.3.2" clj -R:repl build.clj figwheel 8230 <master♺ >
Figwheel: Starting server at http://0.0.0.0:3449
Figwheel: Watching build - dev
Compiling build :dev to "src/public/js/compiled/app.js" from ["src"]...
Successfully compiled build :dev to "src/public/js/compiled/app.js" in 1.164 seconds.
Figwheel: Starting nREPL server on port: 8230
Dirac Agent v1.2.33
Connected to nREPL server at nrepl://localhost:8230.
Agent is accepting connections at ws://localhost:8231.
This is an extract of build.clj
(def compiler-config {:main 'my-app.core
:output-to "src/public/js/compiled/app.js"
:output-dir "src/public/js/compiled/out"
:asset-path "js/compiled/out"
:source-map-timestamp true
:preloads '[devtools.preload dirac.runtime.preload]
:external-config {:devtools/config {:features-to-install :all}
:dirac.runtime/config {:agent-host "192.168.3.2"
:agent-port 8231}}
})
(defmethod task "figwheel" [[_ port]]
(with-namespaces [figwheel-sidecar.repl-api dirac.agent]
(figwheel-sidecar.repl-api/start-figwheel!
{:figwheel-options (cond-> {}
port (merge {:nrepl-port (some-> port Long/parseLong)
:nrepl-middleware [
;"cider.nrepl/cider-middleware"
;"refactor-nrepl.middleware/wrap-refactor"
;"cemerick.piggieback/wrap-cljs-repl"
"dirac.nrepl/middleware"]}))
:all-builds [{:id "dev"
:figwheel {:on-jsload "my-app.core/mount-root"
:websocket-host :server-hostname}
:source-paths [source-dir]
:compiler dev-config}]})
(dirac.agent/boot!)
(when-not port
(figwheel-sidecar.repl-api/cljs-repl))))
This is the output I see on the dirac console
localhost is not where the agent is running. The agent is running on 192.168.3.2
Well, :dirac.runtime/config {:agent-host "192.168.3.2"}
is not being picked up for some reason.
You should be able to ask dirac runtime dirac.runtime.get_pref(cljs.core.keyword("agent-host"))
when in Javascript console at 192.168.3.2:3449. It should return "192.168.3.2" in your case. Alternatively you can check if this value was really emitted in javascript at
http://192.168.3.2:3449/src/public/js/compiled/out/dirac/runtime/preload.js
(or whatever the url is).
Second problem is setting DIRAC_NREPL/WEASEL_REPL/HOST="192.168.3.2", this is definitely not the correct IP you should be setting there with your setup:
VM's IP as seen from your host machine is 192.168.3.2 Host machine's IP as seen from your VM is what?
You must make sure that your VM sees host machine somehow and is able to connect to it in port ranges 8232 - 8242.
Wait, now I realized that you run your browser outside of the VM, not inside as I thought.
Is this your setup?
Then I think all should stay as defaults. Because Dirac Browser Extension connects to Dirac Agent on localhost (on host machine). And weasel inside Dirac Browser Extension also connects to Dirac Agent on localhost (on host machine).
Maybe you could share your skeleton project? I would take a look.
Ah, I'm a bit slower, now I think you are running it this way:
Then you need to:
:dirac.runtime/config :agent-host
to VM's IP as seen from your host machineDIRAC_NREPL/WEASEL_REPL/HOST
to Host machine's IP as seen from your VM
I am running my repl in a different host than localhost in a VM in my computer. The dirac agent is definitely running on my repl but on chrome I get this error
Dirac Agent is not listening at ws://localhost:8231 (need help?).
It should be trying to connect to the agent on other host. Any ideas if I am missing something? I am setting up via preloads and setting host and port as the docs say.