Giter VIP home page Giter VIP logo

Comments (16)

Deraen avatar Deraen commented on May 26, 2024

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.

Deraen avatar Deraen commented on May 26, 2024

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.

frankiesardo avatar frankiesardo commented on May 26, 2024

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!

screen shot 2016-01-08 at 10 04 05

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.

Deraen avatar Deraen commented on May 26, 2024

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.

frankiesardo avatar frankiesardo commented on May 26, 2024

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.

Deraen avatar Deraen commented on May 26, 2024

Usually one uses boot-http or project http server to serve the files.

from boot-reload.

frankiesardo avatar frankiesardo commented on May 26, 2024

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.

Deraen avatar Deraen commented on May 26, 2024

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.

frankiesardo avatar frankiesardo commented on May 26, 2024

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.

Deraen avatar Deraen commented on May 26, 2024

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.

frankiesardo avatar frankiesardo commented on May 26, 2024

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.

martinklepsch avatar martinklepsch commented on May 26, 2024

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.

frankiesardo avatar frankiesardo commented on May 26, 2024

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.

martinklepsch avatar martinklepsch commented on May 26, 2024

Great to hear @frankiesardo! Took me a while to realize that the solution was already there haha.

Cheers! 🍻

from boot-reload.

Deraen avatar Deraen commented on May 26, 2024

I'll be doing release this weekend.

from boot-reload.

Deraen avatar Deraen commented on May 26, 2024

0.4.3 is now available.

from boot-reload.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.