Hey! So I have an issue with figwheel not picking up the :websocket-url config
In the root of project.clj I have the following:
:cljsbuild {:builds [{:id "web"
:source-paths ["src" "env/dev"
"../../../quantum/src/cljc"
"../../../quantum/src/clj"]
:figwheel {:load-warninged-code true
:websocket-url "ws://<IP>/figwheel-ws"}
:compiler {:output-to "./resources/public/js/web/main.js"
:main "env.ios.main"
:output-dir "./resources/public/js/web"
:optimizations :none
:warnings {:redef-in-file false}}}
It hangs on Figwheel: trying to open cljs reload socket
"ws://<IP>/figwheel-ws"
that isn't valid
For the url?
yeah
I tried websocket-host as just <IP> and also :js-client-host
but that didn’t help...
https://github.com/bhauman/lein-figwheel#client-side-configuration-options
I can try that again? Because I just barely pulled out the cljsbuild config from a :dev profile thinking maybe the nestedness was causing issues
Right, I’ve read that
I tried first :websocket-host <IP>
Then :websocket-url ws://<IP>/figwheel-ws”
oh sorry you cleaned the input
thats the actual ip
Haha yes 🙂
Yes e.g. 401.239.144.331 (not the actual IP)
so how are you starting figwheel?
I’m starting it remotely on an AWS instance in the appropriate project directory
sudo LEIN_ROOT=1 lein figwheel web
and you have the port set?
and the AWS port is open
Port 3449 is open in the security settings, yes
When you say the port set, what does that mean?
and the websocket-url has the port in it?
ws://<IP>:<port>/figwheel-ws
Yes
also there is one other thing the webserver is starting on the 0.0.0.0 interface
you may want to set the :server-ip your server ip
Well so there’s the AWS private IP and the elastic IP
I tried setting the :server-ip
to the elastic IP but that failed
so try 127.0.0.1
{:id "web"
:source-paths ["src" "env/dev"
"../../../quantum/src/cljc"
"../../../quantum/src/clj"]
:figwheel {:load-warninged-code true
:websocket-url "<ws://XX.XX.XX.XX:3449/figwheel-ws>"}
:compiler {:output-to "./resources/public/js/web/main.js"
:main "env.ios.main"
:output-dir "./resources/public/js/web"
:optimizations :none
:warnings {:redef-in-file false}}}
As the client
no
But server, :figwheel {:server-ip 127.0.0.1}
oh yea
in the top level figwheel
Yup!
Trying now
(This is what is has been doing btw)
that says localhost
Yes, that’s what it has been doing — like I said, it seems to have not been picking up the config
how are you starting figwheel?
lein ?
script?
sudo LEIN_ROOT=1 lein figwheel web
manually
In the directory where that project.clj is
(Meanwhile I killed figwheel and restarted as per that command, after applying the :figwheel {:server-ip “127.0.0.1”}
edit — maybe it changes things)
do print-config in the figwheel repl
I would if it connected 😉
bummer
so you put this config at the root of your lein project.clj?
the :cljsbuild config
and you are sure your :profiles {:web } isn't overriding it?
(defproject <PROJECT> "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "<http://example.com/FIXME>"
:license {:name "Eclipse Public License"
:url "<http://www.eclipse.org/legal/epl-v10.html>"}
;:git-dependencies [["<https://github.com/alexandergunnarson/quantum.git>"]]
:dependencies
[ ...
[org.clojure/tools.analyzer.jvm "0.6.10"]
[reagent "0.6.0-rc" :exclusions [cljsjs/react cljsjs/react-dom cljsjs/react-dom-server]]
[re-frame "0.8.0-alpha11"]]
:plugins [[lein-cljsbuild "1.1.1" ]
[lein-figwheel "0.5.8"]
#_[oubiwann/lein-git-deps "0.0.3" ]]
:clean-targets ["target/"]
:aliases {"dependencies" ["pdo"
"deps,"
"sudo" "npm" "install"
"sudo" "rnpm" "link"
; When encountering a build error,
; <https://github.com/lelandrichardson/react-native-maps/issues/371#issuecomment-231585153>
]
"prod-build" ^{:doc "Recompile code with prod profile."}
["do" "clean"
["with-profile" "prod" "cljsbuild" "once" "ios"]
["with-profile" "prod" "cljsbuild" "once" "android"]]}
:figwheel {:server-ip "127.0.0.1"}
:cljsbuild {:builds [{:id "web"
:source-paths ["src" "env/dev"]
:figwheel {:load-warninged-code true
:websocket-url "<ws://XX.XX.XX.XX:3449/figwheel-ws>"}
:compiler {:output-to "./resources/public/js/web/main.js"
:main "env.ios.main"
:output-dir "./resources/public/js/web"
:optimizations :none
:warnings {:redef-in-file false}}}
{:id "ios"
:source-paths ["src" "env/dev"]
:figwheel {:load-warninged-code true :websocket-url "<ws://XX.XX.XX.XX:3449/figwheel-ws>"}
:compiler {:output-to "target/ios/not-used.js"
:main "env.ios.main"
:output-dir "target/ios"
:optimizations :none
:warnings {:redef-in-file false}}}
{:id "android"
:source-paths ["src" "env/dev"]
:figwheel {:load-warninged-code true :websocket-url "<ws://XX.XX.XX.XX:3449/figwheel-ws>"}
:compiler {:output-to "target/android/not-used.js"
:main "env.android.main"
:output-dir "target/android"
:optimizations :none
:warnings {:redef-in-file false}}}]}
:profiles {:dev {:dependencies [[figwheel-sidecar "0.5.0-6"]
[com.cemerick/piggieback "0.2.1"]]
:source-paths ["src" "env/dev"]
:repl-options {:nrepl-middleware [cemerick.piggieback/wrap-cljs-repl]}}})
Full project.clj (dependencies elided)
By the way, now trying to connect to <IP>:3449 in the browser says “this site can’t be reached"
(Possibly because of the 127.0.01)
Thanks so much for your help with this by the way! Extremely prompt 👍
Ah… I’m seeing something now… figwheel-sidecar has a different version
Removing that dep and trying again
yeah you have to keep hitting shift reload
or you'll be messing with cached versions
even if you have caching disabled
Ah, okay doing it
Well, after it’s up haha
so I'm thinking it is picking up the config
Also, figwheel has been saying that the :compiler :warnings key isn’t valid
Maybe that’s related?
well it wouldn't start if there is a warning
I press s
Maybe that shadows another warning?
oh well that should work
Also, figwheel’s up again (`Prompt will show when Figwheel connects to your application`), but shift-reload in the browser says refused to connect
to localhost?
or to your elastic ip now
I’ve always been running figwheel from the elastic IP for this particular project
in the client what is it trying to connect to?
The client is my laptop connecting to the elastic IP via Chrome
The elastic IP points to the AWS instance on which figwheel is running
It worked before the 127.0.0.1 edit
so the configuration is making it through
Right, should be
you have the correct websocket url in the client now
The browser doesn’t actually load the page at all is what I’m saying
yes I understand that
When you say “in the client” you mean in project.clj?
get rid of the 127.0.0.1
All right, doing that now
Relaunching figwheel
is your page a static html file?
that is served by figwheel?
Yes
Just a very small index.html I created that references the .js files
Well, possibly one concern is this:
Sorry, trying to pull it up
<html>
<head>
<head>
<!-- <link rel="stylesheet" type="text/css" href="./Fonts/selected-fonts.css"> -->
<!-- <meta name="viewport" content="width=device-width, initial-scale=0.67, maximum-scale=0.67, user-scalable=no"> -->
<!-- <link rel="stylesheet" href="react-virtualized.css"></style> -->
<style type="text/css" id="dynamic"></style>
<style type="text/css" id="default-style">
html, body {
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
::-webkit-scrollbar {
display: none;
}
</style>
<!-- <link rel="stylesheet" href="fixed-data-table.css"></style> -->
<!-- "https://bitwiseshiftleft.github.io/sjcl/sjcl.js" -->
<!-- <script type="text/javascript" src="/js/forge.bundle.js"></script> -->
<!-- <script type="text/javascript" src="/js/crypto-aes.js" ></script> -->
<!-- <script src="js/react-0.14.7.js" type="text/javascript"></script> -->
<!-- <script src="js/react-0.14.7.min.js" type="text/javascript"></script> -->
<script src="/js/npm-deps.js"></script>
<!--<script src="js/pdfjs.worker.min.js"></script>-->
<!-- <script src="js/react-dom-0.14.7.min.js" type="text/javascript"></script> -->
<!-- <script src="js/react-infinite.min.js" type="text/javascript"></script> -->
<!-- <script src="js/bitdash.min.js"></script> -->
</head>
<body>
<script>
var React = quantaRNDeps.React;
var ReactNative = quantaRNDeps.ReactNative;
</script>
<div id=root></div>
<script src="/js/web/goog/base.js"></script>
<script src="/js/web/cljs_deps.js"></script>
<script>if (typeof goog == "undefined") console.warn("ClojureScript could not load :main, did you forget to specify :asset-path?");</script>
<script>if (typeof goog != "undefined") { goog.require("figwheel.connect"); }</script>
<!-- If you put this outside of the <body> it might say 'js/document.-body not defined' -->
<!-- <script src="/js/web/main.js"></script> -->
<script>goog.require("env.ios.main");</script>
</body>
</html>
Ignore the crazy number of comments
I was trying to reference just /js/web/main.js
but I was running into an issue with paths, I believe
Something like goog.base couldn’t be found
so is the page loading now?
Sorry, I got a late start on reloading figwheel — should be another 10 sec
Just kidding, it’s done
Yes, now the page loads
and figwheel doesn't connect?
"Figwheel: trying to open cljs reload socket"
Server side, no connection either
"Prompt will show when Figwheel connects to your application"
in dev tools it is showing that figwheel is trying to connect to your ip:port
?
Yup! "Figwheel: trying to open cljs reload socket”
and you did hit shift reload?
Oh, figwheel isn’t printing out the ip:port combo (That would be nice though)
Doing shift-reload again
like in the error you pasted above
Figwheel: trying to open cljs reload socket
and hangs as usual
could you paste the error?
the devtools error?
utils.cljs?rel=1482193632635:49 > Figwheel: trying to open cljs reload socket
Chrome dev tools right? Not some extension I might not have?
Ah, it’s taking very long to print that out
Always does
Like 60 sec or something? Maybe more
Oh now I see it
socket.cljs?rel=1482195136016:63 WebSocket connection to '<ws://localhost:3449/figwheel-ws>' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
Still localhost
Figwheel works like a charm locally but I’ve always run into errors around non-localhost scenarios and just given up
I’m sure it’ll be just fine in a bit 🙂
ok you need to look at the output file /resources/public/js/web/figwheel/connect/web.cljs
All right, going there
look at the websocket host
I only have connect.cljs
client client.cljs client.cljs.cache.json client.js client.js.map connect.cljs connect.cljs.cache.json connect.js connect.js.map
ok look hat that
Okay
ok look at that
`(ns figwheel.connect (:require [env.ios.main] [figwheel.client] [figwheel.client.utils])) (figwheel.client/start {:load-warninged-code true, :build-id "web", :websocket-url "ws://[[client-hostname]]:3449/figwheel-ws”})`
How is client-hostname localhost?? When location.host
is "52.4.208.191:3449”
?
Anyway the IP isn’t getting put in
Also let me check my dependency tree to make sure figwheel isn’t being overridden by an earlier version or something...
well this makes no sense
Yeah heh it doesn’t 😛
I hope I’m doing something wrong, because that would be easier
please do a lein clean
also get rid of the :warnings key
and make sure that there are no other config errors
I had an old version of figwheel (`0.5.4-7` in dependencies, not the 0.5.8
in plugins) which I updated to 0.5.8
And I’ll do the rest
lein clean
done
Got rid of warnings key and trying again with figwheel
I manually cleaned some things just now by the way because they weren’t in clean targets (the js/web directory for instance)
No config errors
Still loading
look at that file again after compile
Yup
It’s up but I don’t see figwheel/connect
Before and after shift-reloading I still don’t see it
resources/public/js/web/figwheel
shows client client.cljs client.cljs.cache.json client.js client.js.map
client folder shows
file_reloading.cljs file_reloading.js.map heads_up.js socket.cljs.cache.json utils.cljs utils.js.map
file_reloading.cljs.cache.json heads_up.cljs heads_up.js.map socket.js utils.cljs.cache.json
file_reloading.js heads_up.cljs.cache.json socket.cljs socket.js.map utils.js
Still WebSocket connection to '<ws://localhost:3449/figwheel-ws>' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
hmmm look at your main file
Which main file? main.js?
yes web main.js
oh yeah in 5.8 its in memory
var CLOSURE_UNCOMPILED_DEFINES = null;
if(typeof goog == "undefined") document.write('<script src="./resources/public/js/web/goog/base.js"></script>');
document.write('<script src="./resources/public/js/web/cljs_deps.js"></script>');
document.write('<script>if (typeof goog == "undefined") console.warn("ClojureScript could not load :main, did you forget to specify :asset-path?");</script>');
document.write("<script>if (typeof goog != \"undefined\") { goog.require(\"figwheel.connect.web\"); }</script>");
document.write('<script>goog.require("env.ios.main");</script>');
Yeah this is why I don’t use main.js — I use env.ios.main
directly
so there should be a figwheel connect web
Because goog.require(\"figwheel.connect.web\”)
fails
Hmm okay, trying at least
goog.require('figwheel.connect.web’)
-> null
ls
on figwheel directory yields client client.cljs client.cljs.cache.json client.js client.js.map
client
is a folder
No connect
OK so you have all kinds of things going on here
the two versions of figwheel was bad
Heh 😛
really bad
Yes, fixed that though
and you did a clean compile?
Yes
lein clean
and manually removed the js/web folder
This is why it took 212.987 seconds instead of ~40 😛
and the js/web/main.js requires figwheel.connect.web
Hmm right..
then there has to be a figwheel/connect/web.js
Do I need to have something else as a dependency for figwheel.connect.web to be generated?
nope
Hmm let me try to find if figwheel has a weird interaction via lein deps :tree
ok I would run this locally and first get it to connect
and fix you html file
It does connect locally (in some sense) — I just always have used figwheel for this project in the context of React Native (re-natal) so I didn’t have to use figwheel’s 3449, just RN’s 8080
But yeah the lack of 3449 connection is the issue here
Which I think will be fixed by fixing dependencies?
If that doesn’t work I’ll come back
But I know where to look now at least
dude do you want to screen share?
Haha sure 😛 I feel pretty confident about the next step (dependency fixes) and don’t want to take up more of your time but this is a strange enough situation apparently...
I have screenhero
Do you? I can invite you
I have screen here as well
Cool, what’s your username
?
Bruce Hauman
Oops, email I guess (you can delete the address from Slack after I put it into Screenhero)
Screenhero doesn’t do lookups by username
<mailto:bhauman@gmail.com|bhauman@gmail.com>
Thanks!
It says “invitation sent"
I'm in
Thanks so much for all your help!