We are currently investigating whether an SNMP search for printer devices can be performed from a Web browser.
Premise: A web browser (Chrome for the time being) in a clean PC (no OS required).
What I want to do: I want to do UDP communication using only client-side JavaScript.
What i am trying to do is:
1. Install net-snmp (https://www.npmjs.com/package/net-snmp) from npm of Node.js
2. Install browserify (https://www.npmjs.com/package/browserify) from npm in Node.js
3. Convert sample code of net-snmp with browserify
4). Check with a web browser
4 failed when executing dgram.createsocket is not a function error on the client side.
As a result of various investigations, dgram cannot be browsed because dgram is processed inside Node.js,
In general, it is impossible to communicate on the client side other than WebSocket, XHR, and WebRTC.
I understand that UDP socket communication has been retired as a draft in W3C.
(https://www.w3.org/standards/history/tcp-udp-sockets)
Try it
Try replacing A, dgram with chrome-dgram (https://www.npmjs.com/package/chrome-dgram)
Since dgram cannot be used on the client side, I replaced the corresponding part with chrome-dgram and verified it.
SNMP search can be done with this method, but to install and run on the Chrome application
It is a little different from what I want to achieve.
Try replacing B, dgram with dgram-browserify (https://www.npmjs.com/package/dgram-browserify)
This tried replacing dgram with another package dgram-browserify.
As a result, dgram-browserify is created using WebSocket instead of dgram.createsocket
SNMP search could not be performed because the UDP port was not used for transmission.
Try replacing with C, mock-dgram (https://www.npmjs.com/package/mock-dgram)
This is because the data on the PC was exchanged by making it look like UDP communication
UDP communication was not actually performed.
SNMP search from an external program using D, NaCl + PPAPI
We have confirmed that this is also possible, but prepare an external program in addition to the Web browser as in the case A
It is a little different from what I want to achieve because it is necessary.
Because I am a beginner of JavaScript, I don't know much about it, but for me, WebRTC, DNS, etc. from a web browser
Even file descriptors that can communicate with UDP because UDP data is exchanged
Isn't it possible to communicate from the UDP port if you can make it with JavaScript? I think.
Are there any other means of UDP communication (SNMP search) from a web browser than the above means?
that's all, thank you very much.
这篇文章给出了原因:https://gafferongames.com/post/why_cant_i_send_udp_packets_from_a_browser/