Forwards HTTP requests to UDP sockets.
UDP is a common protocol choice for monitoring systems, where the issues of dropped packets and preserving transmission order are typically of lesser importance than the ability to log large numbers of events with minimal overhead. In my case, I need to send client-side RUM data to a UDP monitoring server, but crucially the pages that I am monitoring are being served by a number of different back-end platforms.
Rather than adding a monitoring endpoint to every back-end, it is far simpler for me to create a separate server that can act as a unified proxy, reponsible for sending all of my monitoring data over UDP.
http2udp is a very basic HTTP server that runs on Node.js and forwards requests to UDP sockets, based on the parameters of the request.
Assuming that you already have Node.js and npm, you can install it globally like so:
sudo npm install -g http2udp
Or add it to your project's dependencies
To see a list of command line options, you can run:
Available options are:
Hostname to accept HTTP connections on.
The default is 0.0.0.0 (INADDR_ANY).
Port to accept HTTP connections on.
The default is 8008.
URL path to accept requests to.
The default is /udp.
Allowed origin(s) for cross-domain requests,
The default is *,
specify null to force same origin.
Maximum request body size in characters.
The default is 1024.
Prevent the command
from logging output
to the console.
If the server is running in the foreground, you can terminate it with ^C.
If it is running in the background,
find the pid with
kill -9 it,
var http2udp = ;http2udp;
To install dependencies:
To lint the code:
npm run lint
To run the unit tests: