Comments (16)
Not possible currently I think.
And I'm not sure what would be a solution to this. As far as I know the websocket client needs an address and port. Also, in client code it can be difficult to detect what is the current client.
One solution would be to the same hostname for websocket connection as is used to load the page, but that doesn't solve all cases so I don't think it's worth the complexity.
Maybe you could configure your network so that you have single IP which is accessible from all clients?
from boot-reload.
To setup loopback alias for browser and maybe ios simulator:
# linux?
ifconfig lo: 10.0.2.2 netmask 255.0.0.0 up
# os x?
ifconfig lo0 alias 10.0.2.2
from boot-reload.
Thanks @Deraen you comment made me realise that there is a very easy solution to this problem:
(task-options!
reload {:ws-host (.getHostAddress (java.net.Inet4Address/getLocalHost))})
And voilà, the websocket connects to all three platforms without problems!
However, this story still has no happy ending. When I try to reload on android boot-reload
does a call to GET file:///Users/frankie/Projects/my-app/www/js/app.out/web/core.js?zx=vs40u6q9r42l
(my main namespace) that fails for the same localhost problem. My guess is it should be file://MY_HOST_IP/Users/frankie/Projects/my-app/www/js/app.out/web/core.js?zx=vs40u6q9r42l
. Do you guys know how can I tweak that behaviour (or monkeypatch it?)
from boot-reload.
File urls never work with ips, they are always to local filesystem. Reload client is set to load files from same url as they were initially loaded.
This part of code is where JS files are reloaded: https://github.com/adzerk-oss/boot-reload/blob/master/src/adzerk/boot_reload/reload.cljs#L42-L44
Is there a possibility to get android load files from HTTP server instead?
from boot-reload.
Interesting. Figwheel does not have the same problem because it uses a static file server to serve those files over http://
rather than file://
. Since boot-reload
is already starting a server for the websocket connection it shouldn't be a massive change to serve the files from there?
I don't know if that's the direction boot-reload
wants to go to, but if you think it's a useful addition I'm happy to help implementing this feature.
from boot-reload.
Usually one uses boot-http or project http server to serve the files.
from boot-reload.
Yeah but having it integrated in this plugin means boot-reload
can call reload-js
with a uri like http://host:port/js/out/app.js
instead of file:///Documents/...js/out/app.js
, thus allowing a user to pass a different host and port for emulators, or using something like ngrok with physical devices
from boot-reload.
No, it shouldn't need to be integrated into this plugin. Boot-reload should already reload files over http BUT you probably need to load the HTML over http.
from boot-reload.
BUT you probably need to load the HTML over http.
That's the point. When running on a device (cordova, React Native) the file is not loaded over http. Wouldn't it be nice to support those platforms too?
from boot-reload.
Boot-react-native seems to have some workarounds to make boot-reload work.
It would be nice to support those platforms too but I don't think integrating http server is needed for that. We could either require user to use boot-http or depend on boot-http and compose reload with boot-http to start server, but I would probably prefer the first option if the configuration doesn't get too complex.
Some kind of reload-url-fn or prefix option might be enough.
Do you have some example project I could take a look at?
from boot-reload.
Yes, I have a very sample example pushed at https://github.com/frankiesardo/cadabra.
You can run only the Android platform if you like, that's the one I'm having problems with.
from boot-reload.
maybe the asset-host
option proposed in #52 would help with this as it allows to specify an alternative "root host" to load to-be-reloaded files from instead of deriving it from the intially loaded file?
from boot-reload.
Yes, it works beautifully! Thanks a bunch for the help guys, I've updated the cadabra
project to reflect this change if anyone wants to try it out.
This change is so good that it makes it trivial to use ngrok
and make boot-reload work on real devices remotely. Exciting times ahead.
from boot-reload.
Great to hear @frankiesardo! Took me a while to realize that the solution was already there haha.
Cheers! 🍻
from boot-reload.
I'll be doing release this weekend.
from boot-reload.
0.4.3 is now available.
from boot-reload.
Related Issues (20)
- Warn if :asset-path is specified but does not start with /
- ERROR: Invalid token: ws://localhost:40781 (possible regression) HOT 1
- Reload files where resource path doesn't match web url path HOT 3
- Some confusion on `defrecord` on reloading HOT 1
- Reloading behaviour changes on migration to 2.7 HOT 3
- Web-worker support HOT 1
- 0.5.0 todo HOT 2
- Use of reserved Javascript keyword in adzerk.boot-reload HOT 2
- Not harmful exception at shutdown HOT 4
- Try to optimize page load time with Boot-reload
- Assert on-jsload option from .cljs.edn is a symbol HOT 1
- Closure Library deleted goog.net.jsloader.loadMany HOT 1
- document.write warnings HOT 1
- Reloads before boot-cljs has written resource HOT 27
- Closure library deleted goog.net.jsloader.load HOT 8
- java.lang.ClassNotFoundException: javax.xml.bind.DatatypeConverter (Clojure 1.9 on openjdk 10.0.1 2018-04-17) HOT 5
- Update http-kit for Java 9+ support
- Reload websocket is related to assets? HOT 8
- Cljs-asset-path should end up in js file? HOT 2
- Rename :asset-path HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from boot-reload.