N2O is an embeddable Erlang and JavaScript library for WebSocket, HTTP, MQTT, and TCP servers. It provides process management, sessions, encoders, and a unified API over message buses and caches.
Overview
N2O acts as a message protocol loop you embed in WebSocket, HTTP, MQTT, or TCP servers. It targets high-performance protocol relay with a compact Erlang core and companion JavaScript modules for BERT, UTF-8, heartbeats, FTP, and MQTT client behavior.
Core pieces include OTP supervision, a protocol loop, a hash ring for virtual nodes, and formatters such as JSON and BERT. Optional extensions cover Nitrogen web integration, file transfer, business process engine hooks, and REST-style HTTP APIs over proplist or JSON payloads.
For WebSockets, the loop runs inside handlers on servers like Cowboy, with pub/sub backends such as gproc or syn. For MQTT, documentation describes compatibility with the EMQ broker and RPC-over-MQ patterns where client topics map to server procedures.
Samples range from simple MQTT and WebSocket chat demos to enterprise instant messaging configurations. Distribution is per-file under ISC, and active code reloading is noted for GNU/Linux, Windows, and macOS hosts.
Key features
- Embeddable N2O protocol loop
- WebSocket, MQTT, TCP endpoints
- Virtual node ring for requests
- JSON and BERT formatters
- Cowboy and EMQ integrations
- Optional Nitrogen and BPE protocols
- JavaScript BERT and MQTT helpers
- KVS backends including Redis and Mnesia
Use cases
- WebSocket chat or RPC services
- MQTT application nodes on EMQ
- IoT messaging with consistent delivery
- Erlang apps needing session encoding