How do I access printer SNMP data through JavaScript - javascript

How do I send and receive SNMP queries using JavaScript? I am trying to create a webpage for my employer that can query the company's printers and display toner and paper levels on the webpage. I don't have access to the webserver itself, so I have to implement something client-side using HTML/JavaScript/etc. I did some searching and it looks like JavaScript doesn't have any native SNMP methods or functions, and the JavaScript libraries that I've found (net-snmp, node-snmp-native, node-snmpjs, and several others) all require Node.js, which my company doesn't use.

This is an impossible request. SNMP is a network protocol. Javascript (client-side) has no socket support and can't communicate in any other protocol other than HTTP/HTTPS. The Node stuff is a whole different ball-game, because it's server side.

You can think of two solutions.
Use java snmp client libraries and java swing as front end.
Use Node.js server and snmp.js library.
Solution #2 is a long term solution and you will have more options here.This will give you web UI and it will be nice and useful for future.
Read What client-side web scripting languages are there other than JavaScript and VBScript?
You can find out other client side scripting options. For Perl/Python , you have snmp client library .
Other better option is , use VB Script and IE as client . There are VB Script snmp client libraries. This solution works only for IE.
Thanks

Related

How to connect to MS-SQL database via JavaScript?

I understand this is not best practice but I am operating within a limited realm and, as far as I can tell, this is the only solution to this problem.
I am trying to connect to an MS-SQL database both to get data and to put data onto the database. I cannot seem to do it through JavaScript.
ActiveXObject is, from my understanding, now depreciated so that is not working, which eliminates every functional solution that I could find recommended in the past.
Please note: I am not a web developer and I have no access to any of the standard web development tools for this task.
This is the question has been asked multiple times in various forums - Can my client-side Javascript (running in a browser) connect to a database server and fetch data?
The short answer is - not recommended in general, not feasible without breaching security and without using outdated technologies. Let us dig into it.
It is possible to connect to remote database from a browser using outdated technologies
There are two pieces of technologies from Java and .Net worlds - Applet and ActiveX that run on the browser and can communicate to a remote database. The Java Applet is hardly used by anyone nowadays and browsers are stopping to support it. ActiveX is discontinued by Microsoft in their newer browser Edge. So, you have to enforce your target users to use old insecure browsers if you want to go with these options.
Do not use this.
Use databases embedded in the browser and sync with a remote database
You may use the database locally available in the browser and perform all read/write operations. Periodically sync this database with a remote one. Here are the options:
MongoDB and use change stream to sync with a remote MongoDB
PouchDB and sync with a remote CouchDB or even a MySQL database
Use this only for offline storage temporarily in the browser.
The traditional and secure approach to connect to a remote Database
Use a server-side technology to develop an app that your client-side code (Javascript, HTML) talks to. The app may provide RESTful APIs to interact from the client-side. Then the app that is running in a web server connects and interacts with the database. There are plenty of server-side technologies such as Java, PHP, Python, NodeJS (Javascript based), .Net, etc. to develop your server-side app.
Go with this option.
Well javascript is a client side scripting where as your database runs on a server. So firstly you cannot connect to a database for executing any query from client side i.e javascript and also you need to setup a server side service which can connect to the database and execute the query and give you the result at the client side. You can refer any client-server architecture for this on the web.

Peer-to-peer Javascript & something

I'm looking for a method to connect client(web browser) to server(without external IP) using p2p.
As client-side language i would like to use javascript.
I was reading about WebRTC Peer-to-peer but i don't know if it only works with two clients(javascript) or if i can use some other language ( PHP, Python, Node.js ).
I know about signaling, STUN and TURN servers. I have server with external IP address so it won't be a problem.
My question is what programming language can i use on the server?
Actualy you can avoid other languages if you will use Kurento media server. It have javascript like native. And it frendly desiged to use it with Node.js backend.
Also Janus-Gateawey have commodious JavaScript API and allows build backend on any language you want. Managing all webRTC things happens on client side. That very cose if you understand webRTC and JS at least on basical level.
For control webRTC from back side on python you can use aiortc library
If you need to send/receive only text data then socket.io with e.g. python-socket.io (on server side) is that what you need
I added to Andrey Suglobov's answer: The client does not receive the WebRTC packets from the server because it doesn't have an external IP. In order to solve this problem, you have to configure it to communicate via the TURN server in the middle.
[WebRTC server] ↔ [TURN] ↔ [NAT] ↔ [client]
Generally, the client uses JavaScript because it's a browser. But WebRTC is a specification that supports P2P on the web. If supporting this specification, it does not matter what programming language you use.
Thank you.
Probably found an answer.
I can use javascript server side in node.js

What is the way to use sqlserver with javascript on asp.net?

I'm working on a school project for that I've to make a forum. So I want to make it light using javascript which is run on client side. So regarding this I want to know how can I use sqlserver with javascript on asp.net. I'm new commerce and don't know much about this. I know how to handle it with c# but as every one knows it makes heavy due to run on server side.
You'll need some kind of server-side piece. You can't use JavaScript on the client to talk directly to an SQL Server instance. Even if you could hook it up in terms of the protocol and port and such, A) You'd have problems with security policies, and B) It would be a Really, Really Bad Idea to allow clients direct access to the DB.
So the typical architecture is: Client -> mid-tier -> database
These days it's not atypical for the mid-tier to be some kind of web service exposing a REST, XML, or JSON API.
You have lots and lots of choices for the mid-tier. Certainly C# and ASP.Net is one choice, but only one. There's Ruby on Rails, there's any number of JVM-based frameworks (Java EE, Play!, ...), there's PHP, there's Node.js...
I suppose one choice for the mid-tier is SQL Server itself. SQL Server 2005 offers a built-in set of web services you can enable via SOAP/HTTP. You would probably still run into issues with the Same Origin Policy, since I assume you won't be serving your web pages from the SQL Server. :-) Or maybe you could get around that, by configuring IIS to proxy for the SQL Server's SOAP/HTTP stuff and also to serve your pages, so they'd all be on the same origin (the host and port of the IIS server).

cXML PunchOut Transaction and Javascript

I am researching how to PunchOut enable a webstore and from what I read, I have to use a server side language. Unfortunatly I am limited to only using Javascript. Can this be done? Does anyone have any best practices or can point me to a reference for enabling a PunchOut ecommerce store by only using Javascript?
According to the cXML Users Guide (http://xml.cxml.org/current/cXMLUsersGuide.pdf) on page 23 it states "PunchOut catalogs are made possible by Web server
applications, written in a programming language such as ASP (Active Server Pages),
JavaScript, or CGI (Common Gateway Interface), that manage buyers’ PunchOut
sessions.". Based on that it sounds possible as they call out JavaScript, but they also call out the fact that it is done by Web server applications. I have not used a strictly JavaScript myself, just ASP and recently .NET.
However, I'm not a JavaScript expert so YMMV. The main thing to keep in mind that most punch-outs (especially from Ariba) will be initiated via an HTTP POST with the cXML document XML as a form value. If you can use JavaScript to process that XML and send back a response without server side work, then you should be good to go.

PostgreSQL sockets from JavaScript (HTML5)

I'm looking at options to connect directly--without a web server or middleware--to a PostgreSQL server using JavaScript from a web browser client. On github, I found three projects:
node_postgres
node-postgres
postgres-js
They all appear to be in early but at least somewhat active development.
Do they all do roughly the same thing? Is what they do even what I'm looking for? Does anyone have experience with any of them that could recommend one over the others?
node-postgres was inspired by postgres-js and does roughly the same thing.
However, they both seem to be their own sort of middleware, because they require node.js, which is a server-side JavaScript implementation of a web server. So they would cut out a layer, but still not be the same thing as connecting directly to the PostgreSQL server.
There might be a way to combine the code in them with some HTML5 socket examples, though, to make connections directly from a web browser client.
If you are interested in CLIENT side JavaScript, as the OP's question implied, but you don't insist on owning the server, there is a commercial service that can help you.
The Rdbhost service makes PostgreSQL servers accessible from client-side JavaScript. There is a security system to prevent unauthorized queries, using a server-side white-list and an automated white-list populating system.
It uses plain old AJAX style http requests, provides a jQuery extension to facilitate the querying.
See https://www.rdbhost.com .
There is no secure solution today. One of possible solutions would be htsql:
http://htsql.org/
However there you use web addresses to query, even with https your queries will be plain text!
You should/could use a small webserver to handle requests. Alternativelly you can write an app, or use a local postgres server to handle the connection (in this case you still will need some kind of webserver).
The problem is very simple: your webbrowsers are limited in protocols to talk to the web, and postgres is not on this list. In fact you should not try to overcome this issue, using a server-client architecture is a very good solution. Format your request with JS to make it as small as possible, and let your web-server scripts interpret it into functional sql requests. The answer can be parsed into shorter response, then a sql data transfer, and you just need to interpret it on your side. Since you will create interperers on all sides, you will achieve a higher abstraction then in case of direct db connection, and thus independency towards the backend engines you use.

Categories

Resources