connect to node server finding the mask automatically - javascript

so this is my problem:
I have a node server with a game i'm creating. the node server is listening in a ip mask that is given to him in network, like 192.168.x.x (isn't always the same).
The game 'frontend' is a web page, in a domain (like paperplane.io) that points to my dropbox project and makes it accessible.
How can I make my game frontend, the client, know behind what mask is node server listning, in that network, so it can communicate with it with no specific configuration.
Synthesizing: start node server in local network. every device in that network can access it via web url. plug & play.
thaks

Ok, so i solved my problem by having my node server sending updates to a mysql database with something like: I'm XPTO and I'm at 192.169.X.XX.
so, when i access my application i tell her what i'm looking for (i always know) like this:
XPTO.application.com
by the subdomain i check the database for key:value and get my nodejs ip mask in network.

Related

Local server to serve api requests

I am working on an automation project
I have a local server inside adobe cep. It's a node js/express server.
I want to be able to send an API request to that server from a cloud server.
How can I connect my local server to the web so I can run an HTTPS request that will arrive at my local server?
Thank you very much for helping with this
I didn't really know where to start with this, searched online but didn't get any results yet
This is a two steps configuration, you want to call a local server from the cloud, so:
first of all you need to know your IP (if dynamic it may change)
or you want to use a service like dynDNS so you can associate an ip (192.1.2.3) or an URL (http://myLocalserver) that is callable from the web.
Additionally, you need to setup the port forwarding in your rooter configuration so you can connect your local server (localhost:4200 for instance) to http://myLocalserver:4200

neo4j server side javascript

I have a neo4j desktop (1.4.3) database on my Windows PC. in an html code, I am connectecting to the DB using
const driver = neo4j.driver("bolt://IP_ADDRESS:7687", neo4j.auth.basic("neo4j", "PASSWORD"));
After that I query the DB and display the results on the web page (I use leafletjs maps, but this is not the issue)
var session = driver.session();
session
.run(`MATCH....etc.... return ....
`)
.subscribe({
...... etc
Everything is fine so far. I run the page on my PC or from another PC in my home network, everything is fine. The setting of neo4j is (dbms.default_listen_address=0.0.0.0) no issues there.
The question is how do I expose this page to the colleagues outside my network?
Using noip.com, I got a temporary domain mapped to my external IP.
I also configured the router to forward port 80.
But when the page Javascript gets loaded on an external client, it tries to connect to neo4j on that client. When I put the external IP addtess in "const driver ..." the connection does not work.
How do I make the connection to the DB from my server, but the queries to the DB come from the client who loaded the Javascript?
Edit: Forgot to mention that I am also using Apache Web Server (Xampp) to serve the page to remote users.
A simple architecture that does what you want, plus mitigates the risk of opening up your database to everyone uses a HTTP server + API that are accessible via your noip provider.
Your public facing frontend (HTML + JavaScript (for making API calls etc)) makes the HTTP(s) calls to your publicly accessible API (for example a nodejs server) to make the database calls. Cypher/a direct database connection to neo has no place in your users' browsers.
You can also use a starter like the GRANDstack.

Local node.js server connect to http website

I currently own a website, which will be used for global access and a database. I am also building devices that run a local node.js server, that forms a connection to this website.
So I guess this would be a reverse websocket? I don't own the webserver, it's hosted, so I'd assume I would use php.
I'm needing a 2 way connection that can push or request updates from both ends... Maybe websockets isn't the answer in this case?

Locate server on LAN in JavaScript

TL;DR
In Javascript, how do you to find the IP of all servers running a specified program on a specified port in the LAN?
Background
I'm writing a server in node.js that is supposed to connect users browsers as controllers to a common device on which a game is running. The browsers are running a web app based on html and Javascript. The connection is based on socket.io.
I'd like for the web app to be able to find all available instances of this server in the LAN in order to create a server list for the user to choose from.
Is there a way to make the server discoverable by the web app on the local network in Javascript, and in that case: how?
Ideas
Have the server broadcast its IP to all devices on the LAN and have the web app listen for these messages (No idea how to do this without node on the client)
Connect to every IP on the network and see if the connection is successful. (Does not seem feasible)
Scan every IP on the network and connect only to those where the port is open. (Once again, no idea how to do this without node on the client and does not seeem feasible either.)
EDIT
The server is supposed to be portable and work independently, without any central system backing it up or providing matchmaking for clients. It is a LAN only server and should work even without internet access.
There is no way for you do this. Sorry. Since there is no exposure to UDP on client-side JavaScript, broadcasting is out of question. Any attempt on massive scanning will quickly raise flags on network monitoring software. You have to use a known address.

send command via tcp ip through javascript

I want to achieve following functionality and need the help for the same:
I have one server on which there is device connected that prints some bar codes based on pre-formatted command given to it.
Currently there is one desktop application which generates the command and does the job.
Now I want to do this via web, meaning there will be one webpage (say .aspx) and I want to achieve this by javascript.
I am able to generate the pre-formatted command required for printing but I don't know how to send the command to server, whether socket tcp ip or something else.
I have tried using node.js, socket.io, json-socket etc. but nothing is working,
If javascript is a fixed requirement, then no I don't think you'll find a direct solution. You will need to create an intermediary service that will translate websocket protocol to the tcp/ip protocol your software communicates on. I found a package called Websockify that has implementations of this kind of bridge in a few different languages.
Although if you are open to using Flash on the front end, and can meet the security requirements on your backend connection, then Flash socket API could work. I believe Java applets can also manage this.
I don't believe this is possible to do from inside a web browser. If it were it would be a huge security vulnerability (think about it, you visit an attackers page and all of a sudden your printer starts printing and every shared directory on your network fills to the brim with junk data).
You could run the command on the server (node/.net/anything else...) and have the web platform talk to the server to kick the process off. But that sounds kind of like what you already have set up...
Alternately, if you can change the software on the connected device you could try to give it an HTTP endpoint which responds to POSTs.

Categories

Resources