Comments (17)
We do not have any NATS services in the backend part of the PWA in that case. There is just "nothing NATS" then. There is no need for a backend (so far).
What is more interesting (and I have some examples of that too) is, that you use the internal NATS server but also connect it as a leaf node to the cluster. This way you can add some extra services for the PWA which is separated from the cluster but still use the cluster for everything else. We plan to use something like that for a desktop version of the PWA. Our framework let us run the PWA as a Web view on Windows and on OSX, so that the backend is also installed at the client computer. But we are still prototyping and trying to find the best solution for production. It's just that we prototype in multiple directions right now.
P.S.: I think that the code @mlctrez wrote (using your own socket proxy on the same port) is an excellent variant when you really run the "backend nats-server". I also may create my example with the option on doing that. For what we do, it is not relevant, though.
from go-nats-app.
Thanks @oderwat ..
I've published v1 of goapp-natsws for when you get around to updating your example. I'll be updating my spin-off example to use it shortly. The spin-off example has been updated.
from go-nats-app.
we are thinking along the same lines.
the Leaf node concept is exactly what I was going to try next.
Btw I also just said the same thing on @mlctrez repo also.
My project is for scientists and on desktop and / or Lab server they would be doing just like what you said - running with Embedded Leaf node.
In my use case a public server is envisaged to allow the general public to make calls into the Lab server ( no public IP address ). This is legally required because the Lab Server holds patient data - data must stay on site.
So I might have to run sish / ngrok style Setup.
from go-nats-app.
Anyone know if a Leaf Node NATS Server on a private network can be reachable from a Public nats server ? If yes then I could use this approach to reach Leaf Nats Server running in the Lab.
from go-nats-app.
@gedw99 the leaf server connects to the cluster on a special port. So, you need to be able to connect to the internet from inside the lab. You do not need a connection onto the lab at all.
from go-nats-app.
I do not know if you saw it, but my example lets you connect to the internal nats server (using nats cli tool) and send a request there using the random PWA name (the echo subject). In that case, the PWA is kind of what runs in the lab (as it can't be connected otherwise. It runs in the sandbox of the browser). Still, you can send your data there and let it answer. I find that kind of fascinating, you can "talk with the app in the browser of a visitor of the website", just by sending a message to their service, even from a complete different system (maybe super-clusters and/or cascaded leaf nodes away).
from go-nats-app.
@oderwat thanks for the tips.
Yes the NATS Cli trick works for me well. It is fascinating. NATS is really amazing...
I describe my topology here: https://github.com/gedw99/sc-gio#network-topology
Next steps to prove the network architecture is viable:
-
Put up Public NATS Server on fly.io under a https domain.
-
Then NATS CLI can then be set with that Public NATS Server context, and send a message to it, which should flow to the NATS LEAF Server, and up into the go-app GUI in the browser.
NATS CLI (laptop ) --> NATS Public Server ( fly ) --> NATS Leaf Server ( laptop) --> Go-app GUI ( browser on laptop ).
- Then the opposite flow of sending a message from Browser to Public NATS:
Go-app GUI ( browser on laptop ) --> NATS Leaf server ( laptop) --> NATS Public server (fly) --> CLI ( laptop )
Hopefully it works :)
from go-nats-app.
Put up Public NATS Server on fly.io under a https domain.
- Nats does not run under HTTPS. It uses "nats" protocol which is crude TCP (similar to SMTP or POP3). And that gets TLS on top. The only "web" like way to run the nats server is running it and exposing the websocket.
- You should also add some access control. User/Pass in URL will be OK. But probably you did not mean "public" after all :)
I am uncertain if fly.io is okay for the DSVGO, though. They have European regions but depending on the data you need this agreement about data processing (I believe). We run a 3 node cluster for NATS on dedicated servers, and use that as well for replicas of the data (kv / jetstream). I would be interested in the network through output and core utilization for fly.io.
For prototyping, I would get a real root server (8 cores 16+ GB RAM, and it can be used for the production later too) or do everything local in docker or with another server in the local net. Doing it in docker does not "show the real thing" because the network will be much faster than in a real setup.
from go-nats-app.
About points 1 and 2. Yes i know what you mean.. I will see if i can gen the TLS certs using mkcert.
Good point about DSVGO. !!! I want the scientists to put up the Public NATS Server themselves. It's their system. I suggested Fly because its very easy compared to many others.
Fly throughput, will be sucky, but quite good enough for their needs in general i hope.
from go-nats-app.
Just realised how hardcoded the IP:PORTS are. Would you be open to having ENV driven IP and PORT ?
from go-nats-app.
ah. also just realised i need to modify the config for NATS in order for the embedded NATS server to act as a leaf node ..
What if modify and PR the code in "back.go" to allow configuring itself as a NATS Leaf Server and / or NATS Server ?
The intent is to allow both scenarios depending on needs.
from go-nats-app.
As this code does not use any of our real framework code, I do not want to modify anything here. Read the disclaimer, I was not joking there ;-). Actually, I also just accidentally posted this under my private account instead of the one from the company, and now it is a bit too late to change that :)
I do appreciate your input and like to share my thoughts and watch your enthusiasm :)
We do have PWAs prototypes with leaf code and stuff. This here is just a "copy & paste" I did in a "free" hour, grabbing from some code I wrote for internal projects. I posted this to the NATS Slack / devs after they took my PR to make it possible to use the nats-server web socket from inside of WASM. They were curious for what I need it.
from go-nats-app.
I want the scientists to put up the Public NATS Server themselves.
If paying for a service is an option, they may go with NGS and use a European region instead of running your own little one node server.
from go-nats-app.
I want the scientists to put up the Public NATS Server themselves.
If paying for a service is an option, they may go with NGS and use a European region instead of running your own little one node server.
yep that's another option - good option actually.
from go-nats-app.
As this code does not use any of our real framework code, I do not want to modify anything here. Read the disclaimer, I was not joking there ;-). Actually, I also just accidentally posted this under my private account instead of the one from the company, and now it is a bit too late to change that :)
I do appreciate your input and like to share my thoughts and watch your enthusiasm :)
We do have PWAs prototypes with leaf code and stuff. This here is just a "copy & paste" I did in a "free" hour, grabbing from some code I wrote for internal projects. I posted this to the NATS Slack / devs after they took my PR to make it possible to use the nats-server web socket from inside of WASM. They were curious for what I need it.
ok i can see what your mean. I will work up a repo. I appreciate the advice and this repo for helping me.
from go-nats-app.
If you know where the PR is that enabled WASM for NATs, let me know. Would be interesting to see the changes that made it possible just out of curiosiity.
from go-nats-app.
I needed I way to suppress that the NATS Go client does the TLS handshake when the server requests TLS because the handshake was already done through the custom dialer (because it uses wss).
from go-nats-app.
Related Issues (5)
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 go-nats-app.