Access a service running on localhost with Javascript - javascript

The case is quite straight forward (in my mind). The client has a native application running on his machine that produces pairs of values. What I am trying to accomplish is when this service is running and the user visits my web service I want to be able to retrieve these pairs of values with JavaScript code on the clients browser. I haven't decided because I am not sure what kind of server should create the pairs or how to grap them with JS. I have tried using pubnub to setup a channel of communication but the round trips are kind of slow.
Any suggestions?

You could access a local http server (LAMP / WAMP) for AJAX calls with javascript via the 127.0.0.1 or localhost addresses.

Related

what is the different between building server side VS API

so currently i am studying web development but the course was a little bit confusing, the teacher starts explain promise object and fetch then axios, after that he starts to talk about the "express" package to build server side, and am asking myself what is the different between using API objects & building server side using express?
Both of those things work together to create a website/app. axios, etc runs in the browser (client-side code), and is used to send requests to the server (express/other server-side code), allowing the server to fetch data, or modify the database, and return a response back to the browser side code, which continues operating from there.
imagine, client-side code does not have access to your server's database, as your database is on the server, and the browser is on the end user's computer. The two sets of code send messages back and forth to each other to create an app that has a centrally stored data store that is "shared" between users.

How to handle encrypted requests and answers with distant server using a certain protocol with react native and javascript

I'm working on a mobile application project using react native, the mobile app should use a distant server to get information
for example: to log in I must send an encrypted request to a distant server with the certain protocol for example :
03000F10081B367ACF10500019601010200
0300- Command
OF10 - Data length
081B367A -Time
etc...
the answer also will be like that and I have also to encrypt and decrypt all
So my question is how can I handle that? are there any techniques or libraries to easily do it? and should I use an API in my app?
can I program the encrypt and decrypt functions in javascript and integrate them to post and get HTTP requests?
after the login, I must display certain information that I need to send requests to the server to obtain them the same way as the login (encrypted message, protocol, etc ...)
all functionalities should be like already mentioned (connection status, battery level ....)

Need some hint on how to start porting my application

We have two applications, one called flexOS locally on "the server", and one called flexVisu remote on "the client". The first one is doing the job, collection data and such things.
Historically those two applications are able to communicate via TCP/IP sockets and a proprietary binary protocol.
Now we want to replace the client application flexVisu with a web page hosted on the IIS locally on the server. Every web browser on every device should be able to display these web page(s).
Firstly we experimented with an additional application (flexVisuWebServer) on the IIS side that basically hosted a web socket server and translated the json data from the client into binary data for the server and vice versa.
But this always requires a http connection and a wss connection to be open at the same time.
I don't know why, but I don't like the idea of using javascript on the client to handle all the data processing to display the server data.
I think that it would be much easier if I wrote an asp.Net c# application that handles the connection to "the server" via our proprietary TCP/IP protocol. That way no conversion of data between binary and json format must be done, and the web page itself can be also written in C#.
This approach much more resembles the current approach with flexVisu connecting directly to flexOS, the binary data is directly used to fill in Windows Forms controls.
What am I missing here?
Would the asp.Net application be able to connect to a tcp socket and use our own protocol?
[Edit: 2021-02-09 at 16:18 localtime]:
I managed to use our proprietary TCP/IP protocol to connect from the web server to the flexOS in the page_load of the asp.net web page.
So basically it should not be a problem to use the underlying library to read data directly from the flexOS.
OT: Should i post subsequent ASP.Net questions here too, or open some more questions?
We decided to follow this concept:
the webpage is using a websocket connection to our application flexVisuWebServer and this application uses our propietary TCP/IP protocoll to talk with flexOS.

Using Active Directory (with LDAP) to authenticate on an angularjs/javascript fronted - what should the flow of the process be?

I'm working on a project in which we need to authenticate the user in an application by using his/hers windows credentials. Frontend is using Angularjs and backend java.
After doing a sensible amount of research, I discovered that there is no way on the the frontend to obtain directly the Windows user & pass due to security concerns.
But I'm thinking that the whole process should start here, from the frontend, by obtaining these two encrypted credentials or at least a token and sending them to the backend in order to kickstart the ntlm authentication process.
And also, not sure if the user should have to log in the app by typing his windows credentials or if it should automatically be done with ntlm passthrough.
I do not have a good grip on the concept, and that is because most of the related sources that I found are referring to backend solutions (C# 80% of them), but almost nothing for fronted. So, I humbly require some clarifications on this topic. Is there some sort of middleware or npm package that I should use in order to obtain the user & pass, or what would you advise?
Web servers expose certain server variables to code handling requests they serve.
For me, using IIS, these are described here: https://learn.microsoft.com/en-us/previous-versions/iis/6.0-sdk/ms524602%28v%3dvs.90%29
Since I am using IISNode; my node.js environment is completely embedded into IIS; I have access to these server variables. As the link described, each programming language seems to have their own way to access these variables.
So I would doubt it if Java does not have those as well. The exact code to use will depend on you back end.
But a quick search for "java server variables" already yields me the following:
https://docs.oracle.com/cd/E19534-01/820-3288/gawim/index.html for the java access manager.
http://users.polytech.unice.fr/~buffa/cours/internet/POLYS/servlets/Servlet-Tutorial-CGI-Variables.html for old school JSP.
How can I obtain server variables using apache wicket 1.54? for java wicket server.
So have a look at the documentation of your specific web server software or Java API.
There should be a list and example code of how to access these.
Once you obtain this data server side, you can do the LDAP query and then return the results client side.

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?

Categories

Resources