This question is about the basic feasibility of this project but you are welcome to recommend ideas on how it could be done. I would like to create a hosted Java web application that creates a Server in the local network of the device.
For example: You can go to example.com in your Browser and start the application that creates a server in the local network of the device (Windows-PC). Other devices (Android) can connect to the server (UDP) with an installed Android-App.
Is this concept possible? I am afraid browser security renders this level of access impossible..
As others have pointed out it is not possible.
I will instead choose a local Java application that has to be installed.
Related
I got a problematic assignment from my employers.
I was given the task of developing simple software that will run strictly on Google Chrome,
without attempting to connect to the web (Security reasons).
I know flutter development and I feel comfortable with the sdk.
How should I develop a web app that can be deployed using a usb stick?
Looks like PWA can be an option, but the documentation is lacking in detail.
The system does not have the ability to run a local web server.
The Flutter app must be able to work with JS libraries, I intend to use jsQR.
service workers and indexedDB could help you for develop offline route app and offline api.
mdn docs for service workers
I'm not sure that this will fit your particular case: you say that the system can't run a local webserver, but what if you provide the webserver along with your software?
I just discovered get_server: you can find it here. It aims to allow developers to host their own HTTP server by using only flutter, without resorting to external tools or other coding/scripting languages. It allows also (and that's the relevant part) to wrap your flutter web app and make it run on local network.
For now I only tried with a very simple example, but it seems to be working. These are the steps I took:
create a new flutter project: since I needed the webserver to run on Windows, I had to get flutter ready for that (see here for help)
add get_server to the new pubspec.yaml
run flutter build web on your flutter web project, and copy the build/web output
folder in the root folder of the new project (I renamed the folder while copying since flutter might change the content of the web folder)
delete all the content of lib/main.dart
paste this (this the actual content of main.dart)
import 'package:get_server/get_server.dart' as gs;
void main() {
gs.runApp(
gs.GetServerApp(home: gs.FolderWidget('folderName')),
);
}
folderName is the name of the renamed folder containing the flutter web app build.
I ran this on Windows 'device' from AndroidStudio, and my original flutter web app was reachable at localhost:8080 (for now I just used the default options of get_server). I also got the webserver (empty) GUI as a white window: I guess that can be useful for some information regarding the server itself, although, if that windows closes, localhost:8080 becomes unavailable.
But, once released, you should be able to just run the executable from the USB stick, and then connect to it with Chrome.
PS: after some time using GetServer, I had to switch to other packages because of not-so-good docs and support. Now I'm using shelf, but also Alfred is a notable mention.
If I have a Node.js app running on a machine on the LAN that runs a web server (Fastify) and it is configured to be accessible to all devices on the LAN, how could I use JavaScript in the browser on another machine to detect that server on the LAN?
Example: On a NAS connected to my router, I run a Docker container that creates a HTTP API at the address 192.168.1.28:3000. I can manually type this into any browser on the LAN and it will access the Docker container. How can I use JavaScript to detect the existence of this server without knowing its address?
You can't.
While there are protocols for announcing the presence of a service on a network, none are supported by JS running in a webpage.
Browser extensions (such as Bonjour Browser and the poorly reviewed Railduino Zeroconf-Lookup) are possible, but since you didn't mention writing a browser extension I'll assume they aren't an option.
There's things like WebRTC but unless your device advertises that you're out of luck.
This is by design.
Can you imagine if an arbitrary web page could scan your local network and report back to some arbitrary server what it discovers?
I want to set up a bunch of raspberry pies that each run a webserver, and then allow people to simply go to a website on their laptop and get an overview of all of these raspberries on the network (and then of course they'll be able to do stuff with them by calling the web server).
Is it possible to set up the raspberry pies in such a way that they are discoverable on the local network from JavaScript? Without the need of a server? Or is this only possible from native apps?
Allow devices an access to your local network (Just Google OSX local network port, Raspberian network access)
Then use any discovery library that you want.
I'd suggest using something like Cote NodeJS (easly runs on raspbery and any device) - it discovers any other process running cote on local network automaticly;
You can also build your own discovery script or just configure in advance
You could install node.js on your raspberry pies and install socketio on your pies. Then you could simply interactive with them from the client side
In our web application, we using a Java applet to invoke MS.Word application by jacob jar e.g. Word to open, edit, and when it saves automatically it uploaded to the server.
Google Chrome will no longer support NPAPI, so soon we can not run our applet in Chrome anymore.
So, any suggestions for an alternative for the Java applet. We want to make the same experience for the user, just like before.
We have the same problem. With Webstart is not longer possible to do that communication. We are going to use Websockets between webstart application and browser. Our first attempt is to start a websockets server in the webstart and make browser connect to localhosts. If this is not possible for security limitations in the browsers then we are going to do it through the webserver, browser and webstart application connecting to the webserver and exchanging messages.
I can see 2 distinct possibilities.
Create a standalone application that "wraps" your web application using a technology such as electron. You can then do your browser to desktop integration as you like. This will require an install on the client.
Launch a webstart application (or it could really be any installation that happens on the client). It will need to start a webserver, or connect to a webserver and communicate via http.
I'm saddened by the loss of the Applet. It is a technology not easily replaced. And another methods seem somewhat like 'workarounds'. There is no easy, cross-browser way to break out of the browser sandbox and access the system.
For myself, the loss of the Applet has simply meant that automating some of these processes has become too difficult and it is just better to find an alternative way of achieving a similar end result.
A small note: If you are starting a local webserver, be mindful of security. It can be accessed by other processes on the system. Wouldn't it be fun to open word on anyone's system by sending a request to a port!
We have a legacy software package made for native Windows. I'm writing a system to automate installing updates. One of the options is for the client to visit a web page, and from that web page, check for updates to their installation. There are two ways of identifying the software version: either reading a particular EXE file and looking at its file version, or reading the registry for our software (actually the third way is reading from their SQL Server database but that's obviously out of the question). Either of these methods would work, but I have no idea how to do it from javascript in a browser.
I'm sure there is some security, but I have seen other systems do this, so I'm sure it's possible. In general, the web page can check the client's computer for existence of certain software, and if it exists, check for the version. How can I do this from Javascript?
In MaVRoSCy's comment above: "only in IE this is possible with some ActiveX help, except if you run a dedicated local server just to serve this functionality". This actually fits perfectly, because each client computer already has a Windows Service running in the background at all times.
A simple HTTP server can be added into this client service listening on a universal non-common port number such as 16580. This HTTP server can handle requests like /currentversion which returns the current application version.
The javascript on the web page (hosted elsewhere but viewed on that client's browser) calls http://127.0.0.1:16580/currentversion to obtain the latest version.
One of the options is for the client to visit a web page, and from that web page, check for updates to their installation
Bad idea and wrong methodology
Checker|Updater have to be embedded into app
Checker have to (on start|on demand|whatever)
identify build of local app (any usable way)
Get && parse external permanent URL with data of Latest Existing Build (at least version and URL of Build)
Inform, if needed, about new version and|or download|update core, if requested by user|configuration