Web browser as web server
Asked Answered
C

2

11

Sorry if this is a dumb question that's already been asked, but I don't even know what terms to best search for.

I have a situation where a cloud app would deliver a SPA (single page app) to a client web browser. Multiple clients would connect at once and would all work within the same network. An example would be an app a business uses to work together - all within the same physical space (all on the same network).

A concern is that the internet connection could be spotty. I know I can store the client changes locally and then push them all to the server once the connection is restored. The problem, however, is that some of the clients (display systems) will need to show up-to-date data from other clients (mobile input systems). If the internet goes down for a minute or two it would be unacceptable.

My current line of thinking is that the local network would need some kind of "ThinServer" that all the clients would connect to. This ThinServer would then work as a proxy for the main cloud server. If the internet breaks then the ThinServer would take over the job of syncing data. Since all the clients would be full SPAs the only thing moving around would be the data - so the ThinServer would really just need to sync DB info (it probably wouldn't need to host the full SPA - though, that wouldn't be a bad thing).

However, a full dedicated server is obviously a big hurdle for most companies to setup.

So the question is, is there any kind of tech that would allow a web page to act as a web server? Could a business be instructed to go to thinserver.coolapp.com in a browser on any one of their machines? This "webpage" would then say, "All clients in this network should connect to 192.168.1.74:2000" (which would be the IP:port of the machine running this page). All the clients would then connect to this new "server" and that server would act as a data coordinator if the internet ever went down.

In other words, I really don't like the idea of a complicated server setup. A simple URL to start the service would be all that is needed.

I suppose the only option might have to be a binary program that would need to be installed? It's not an ideal solution - but perhaps the only one? If so, are their any programs out there that are single click web servers? I've tried MAMP, LAMP, etc, but all of them are designed for the developer. Any others that are more streamlined?

Thanks for any ideas!

Colure answered 16/6, 2014 at 17:33 Comment(2)
This is a beautiful approach you've taken to provide a service like this. I presume you found your solution? How well did it work?Lazybones
WebVM does this, for example. It can run a server in a Linux container in a browser and allow other browsers to connect to it through Tailscale Funnel.Sanies
L
9

There are a couple of fundamental ways you can approach this. The first is to host a server in a browser as you suggest. Some example projects:

Another is to use WebRTC peer to peer communication to allow the browsers share information between each other (you could have them all share date or have one act as a 'master' etc deepening not he architecture you wanted). Its likely not going to be that different under the skin, but your application design may be better suited to a more 'peer to peer' model or a more 'client server' one depending on what you need. An example 'peer to peer' project:

I have not used any of the above personally but I would say, from using similar browser extension mechanisms in the past, that you need to check the browser requirements before you decide if they can do what you want. The top one above is Chrome based (I believe) and the second one is Firefox. The peer to peer one contains a list of compatible browser functions, but is effectively Firefox and Chrome based also (see the table in the link). If you are in an environment where you can dictate the browser type and plugins etc then this may be ok for you.

The concept is definitely very interesting (peer to peer web servers) and it is great if you have the time to explore it. However, if you have an immediate business requirement, it might be that a simple on site server based approach may actually be more reliable, support a wider variety of browser and actually be easier to maintain (as the skills required are quite commonly available).

BTW, I should have said - 'WebRTC' is probably a good search term for you, in answer to the first line of your question.

Laurentia answered 16/6, 2014 at 21:25 Comment(4)
Thanks! That's better info then I realized was available. I heard about RTC but thought it was only video - reading about it now and it sounds like peer-to-peer data is great for it, too. But, you're right in that installing a server may be easier at the moment. I'll keep on researching. Thank you very much for your input!Colure
Good luck! Maybe you can update here in a comment or another answer if you find a reliable peer to peer solution you are happy with.Laurentia
I will. So far WebRTC seems like the best option since I can "force" users to use particular machines & browsers. Thanks, again.Colure
In order to run an HTTP server in a web browser, I could run a Linux server on the client-side in WebVM and connect clients to the server through Tailscale Funnel.Sanies
A
3

httprelay.io v.s. WebRTC

Pros:

  • Simple to use
  • Fast
  • Supported by all browsers and HTTP clients
  • Can be used with the not stable network
  • Opensource and cross-platform

Cons:

  • Need to run a server instance
  • No data streaming is supported (yet)
Angkor answered 24/4, 2020 at 6:13 Comment(1)
Thanks for this! I've been pondering various ways to implement P2P without bitttorrent-tracker servers, and this is certainly an alternative I was looking for!Wellpreserved

© 2022 - 2024 — McMap. All rights reserved.