Convert Figma logo to code with AI

emitter-io logoemitter

High performance, distributed and low latency publish-subscribe platform.

3,821
352
3,821
13

Top Related Projects

9,053

Real-time Geospatial and Geofencing

High-Performance server for NATS.io, the cloud and edge native messaging system.

Scalable real-time messaging server in a language-agnostic way. Self-hosted alternative to Pubnub, Pusher, Ably. Set up once and forever.

4,391

Simple pub/sub messaging for the web

Quick Overview

Emitter is a scalable real-time communication platform and distributed publish-subscribe messaging system. It provides a high-performance, secure, and fault-tolerant infrastructure for building real-time applications and IoT solutions.

Pros

  • High performance and low latency, capable of handling millions of concurrent connections
  • Supports various communication patterns, including publish-subscribe, request-response, and presence
  • Offers end-to-end encryption and secure communication channels
  • Provides SDKs for multiple programming languages and platforms

Cons

  • Limited documentation and examples for advanced use cases
  • Steeper learning curve compared to simpler messaging systems
  • Community support may be less extensive than more popular alternatives
  • Some advanced features require a commercial license

Code Examples

  1. Connecting to Emitter and subscribing to a channel:
const emitter = new Emitter();
emitter.connect({ host: 'emitter.domain.com', port: 8080 })
  .then(() => {
    emitter.subscribe({
      key: 'YOUR_CHANNEL_KEY',
      channel: 'test/channel'
    });
  });
  1. Publishing a message to a channel:
emitter.publish({
  key: 'YOUR_CHANNEL_KEY',
  channel: 'test/channel',
  message: 'Hello, Emitter!'
});
  1. Using presence to track online users:
emitter.presence({
  key: 'YOUR_CHANNEL_KEY',
  channel: 'test/channel',
  status: true,
  changes: true
});

emitter.on('presence', function(response) {
  console.log('Presence update:', response);
});

Getting Started

  1. Install Emitter using npm:

    npm install emitter-io
    
  2. Import and create an Emitter instance:

    import Emitter from 'emitter-io';
    const emitter = new Emitter();
    
  3. Connect to an Emitter server:

    emitter.connect({ host: 'your-emitter-server.com', port: 8080 })
      .then(() => console.log('Connected to Emitter'))
      .catch(error => console.error('Connection failed:', error));
    
  4. Subscribe to a channel and handle incoming messages:

    emitter.subscribe({
      key: 'YOUR_CHANNEL_KEY',
      channel: 'example/channel'
    });
    
    emitter.on('message', function(msg) {
      console.log('Received message:', msg.asString());
    });
    

Competitor Comparisons

9,053

Real-time Geospatial and Geofencing

Pros of Tile38

  • Specialized in geospatial data storage and querying
  • Supports complex geofencing operations
  • Offers a Redis-compatible protocol for easy integration

Cons of Tile38

  • Limited to geospatial data, less versatile for general-purpose messaging
  • May require additional infrastructure for non-geospatial use cases
  • Steeper learning curve for non-geospatial developers

Code Comparison

Tile38:

SET fleet truck1 POINT 33.5123 -112.2693
NEARBY fleet POINT 33.5124 -112.2694 100

Emitter:

emitter.Publish("truck1", "33.5123,-112.2693")
emitter.Subscribe("fleet", func(msg emitter.Message) {
    // Handle message
})

Key Differences

  • Tile38 focuses on geospatial operations, while Emitter is a general-purpose publish-subscribe messaging system
  • Tile38 uses a Redis-like command structure, Emitter uses a more traditional pub-sub API
  • Tile38 excels in location-based queries and geofencing, Emitter is better suited for real-time messaging across various topics

Use Case Recommendations

  • Choose Tile38 for projects heavily reliant on geospatial data and complex location-based queries
  • Opt for Emitter when building real-time messaging systems with diverse topic structures and non-geospatial data

High-Performance server for NATS.io, the cloud and edge native messaging system.

Pros of NATS Server

  • More mature and widely adopted, with a larger community and ecosystem
  • Supports multiple programming languages and platforms
  • Offers advanced features like clustering and security options

Cons of NATS Server

  • More complex configuration and setup compared to Emitter
  • Steeper learning curve for beginners
  • Lacks built-in MQTT support (requires additional components)

Code Comparison

NATS Server (Go):

nc, err := nats.Connect(nats.DefaultURL)
if err != nil {
    log.Fatal(err)
}
defer nc.Close()

Emitter (Go):

c, err := emitter.Connect("tcp://localhost:8080", func(c *emitter.Client) {
    c.SetCredentials("key")
})
if err != nil {
    panic(err)
}

Both NATS Server and Emitter are messaging systems, but they have different focuses. NATS Server is a more comprehensive solution with a broader range of features and language support, making it suitable for complex, distributed systems. Emitter, on the other hand, is designed to be simpler and more lightweight, with built-in MQTT support and easier setup, making it a good choice for IoT applications and scenarios where simplicity is preferred.

The code comparison shows that both systems have relatively straightforward connection processes, but Emitter's API is slightly more concise and includes credential setting in the connection function.

Scalable real-time messaging server in a language-agnostic way. Self-hosted alternative to Pubnub, Pusher, Ably. Set up once and forever.

Pros of Centrifugo

  • More extensive documentation and examples
  • Built-in WebSocket, SockJS, and SSE support
  • Flexible authentication mechanisms

Cons of Centrifugo

  • Steeper learning curve due to more complex configuration
  • Limited support for custom plugins compared to Emitter

Code Comparison

Centrifugo configuration (JSON):

{
  "token_hmac_secret_key": "secret",
  "api_key": "api_secret",
  "admin_password": "admin_secret",
  "admin": true
}

Emitter configuration (YAML):

listen: ":8080"
cluster:
  name: "emitter"
  listen: ":4000"
security:
  key: "tNMSvIQFYHVKzQYDGDcTHbpDlMBSsoCD"

Both Emitter and Centrifugo are real-time messaging systems, but they have different approaches to configuration and features. Centrifugo offers more built-in transport options and authentication mechanisms, while Emitter provides a simpler setup process and better support for custom plugins. The choice between the two depends on specific project requirements and the desired level of customization.

4,391

Simple pub/sub messaging for the web

Pros of Faye

  • Supports multiple transport protocols (WebSocket, EventSource, long-polling)
  • Easier to integrate with existing web applications
  • More mature project with longer history and wider adoption

Cons of Faye

  • Less performant for high-throughput scenarios
  • Limited built-in security features compared to Emitter
  • Lacks some advanced features like message retention and offline support

Code Comparison

Faye (client-side JavaScript):

var client = new Faye.Client('http://localhost:8000/faye');
client.subscribe('/channel', function(message) {
  console.log('Received message:', message);
});

Emitter (client-side JavaScript):

var client = emitter.connect();
client.subscribe({
  key: 'key',
  channel: 'channel'
}).on('message', function(message) {
  console.log('Received message:', message);
});

Both Faye and Emitter are pub/sub messaging systems, but they have different focuses. Faye is more geared towards web applications and offers flexibility in transport protocols. Emitter, on the other hand, is designed for high-performance, real-time communication with built-in security features.

Faye is easier to integrate into existing web applications and has a longer history, which may translate to better stability and community support. However, Emitter offers better performance for high-throughput scenarios and includes more advanced features out of the box, such as message retention and offline support.

The code comparison shows that both libraries have similar ease of use for basic pub/sub operations, with slightly different syntax and connection methods.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

kelindar/column
Go Version Go Report Card Coverage Twitter

Emitter: Distributed Publish-Subscribe Platform

Emitter is a distributed, scalable and fault-tolerant publish-subscribe platform built with MQTT protocol and featuring message storage, security, monitoring and more:

  • Publish/Subscribe using MQTT over TCP or Websockets.
  • Resilient, highly available and partition tolerant (AP in CAP terms).
  • Able to handle 3+ million of messages/sec on a single broker.
  • Supports message storage with history and message-level expiry.
  • Provides secure channel keys with permissions and can face the internet.
  • Automatic TLS/SSL and encrypted inter-broker communication.
  • Built-in monitoring with Prometheus, StatsD and more.
  • Shared subscriptions, links and private links for channels.
  • Easy deployment with Docker and Kubernetes of production-ready clusters.

Emitter can be used for online gaming and mobile apps by satisfying the requirements for low latency, binary messaging and high throughput. It can also be used for the real-time web application such as dashboards or visual analytics or chat systems. Moreover, Emitter is perfect for the internet of things and allows sensors to be controlled and data gathered and analyzed.

Tutorials & Demos

The following video tutorials demonstrate various features of Emitter in action.

FOSDEM 2018 FOSDEM 2019 PubSub in Go Message Storage Using MQTTSpy ISS Tracking Self-Signed TLS Monitor with eTop StatsD and DataDog Links & Private Links Building a Client-Server app with Publish-Subscribe in Go Distributed Actor Model with Publish/Subscribe and Golang Online Multiplayer Platformer Game with Emitter Keeping one Last Message per Channel using MQTT Retain Load-balance Messages using Subscriber Groups

How to Deploy

Local Emitter Cluster K8s and DigitalOcean K8s and Google Cloud K8s and Azure

Quick Start

Run Server

The quick way to start an Emitter broker is by using docker run command as shown below.

Notice: You must use -e for docker environment.You could get it from your docker log.

docker run -d --name emitter -p 8080:8080 --restart=unless-stopped emitter/server

Alternatively, you might compile this repository and use go get command to rebuild and run from source.

go get -u github.com/emitter-io/emitter && emitter

Get License

Both commands above start a new server and if no configuration or environment variables were supplied, it will print out a message(or you could find it in the docker log) similar to the message below once the server has started :

[service] unable to find a license, make sure 'license' value is set in the config file or EMITTER_LICENSE environment variable
[service] generated new license: uppD0PFIcNK6VY-7PTo7uWH8EobaOGgRAAAAAAAAAAI
[service] generated new secret key: JUoOxjoXLc4muSxXynOpTc60nWtwUI3o

This message shows that a new security configuration was generated, you can then re-run EMITTER_LICENSE set to the specified value. Alternatively, you can set "license" property in the emitter.conf configuration file.

Re-Run Command

References are available. Please replace your EMITTER_LICENSE to it.

docker run -d --name emitter -p 8080:8080 -e EMITTER_LICENSE=uppD0PFIcNK6VY-7PTo7uWH8EobaOGgRAAAAAAAAAAI --restart=unless-stopped emitter/server

Generate Key

Finally, open a browser and navigate to http://127.0.0.1:8080/keygen in order to generate your key. Now you can use the secret key generated to create channel keys, which allow you to secure individual channels and start using emitter.

Warning: If you use upon command, you secret is JUoOxjoXLc4muSxXynOpTc60nWtwUI3o. And it's not safe!!!

Usage Example

The code below shows a small example of usage of emitter with the Javascript SDK. As you can see, the API exposes straightforward methods such as publish and subscribe which can take binary payload and are secured through channel keys.

// connect to emitter service
var connection = emitter.connect({ host: '127.0.0.1' });

// once we're connected, subscribe to the 'chat' channel
emitter.on('connect', function(){
    emitter.subscribe({
        key: "<channel key>",
        channel: "chat"
    });
});

// publish a message to the chat channel
emitter.publish({
    key: "<channel key>",
    channel: "chat/my_name",
    message: "hello, emitter!"
});

Further documentation, demos and language/platform SDKs are available in the develop section of our website. Make sure to check out the getting started tutorial which explains the basic usage of emitter and MQTT.

Command line arguments

The Emitter broker accepts command line arguments, allowing you to specify a configuration file, usage is shown below.

-config string
   The configuration file to use for the broker. (default "emitter.conf")

-help
   Shows the help and usage instead of running the broker.

Configuration File

The configuration file (defaulting to emitter.conf) is the main way of configuring the broker. The configuration file is however, not the only way of configuring it as it allows a multi-level override through environment variables and/or hashicorp Vault.

The configuration file is in JSON format, but you can override any value by providing an environment variable which follows a particular format, for example if you'd like to provide a license through environment variable, simply define EMITTER_LICENSE environment variable, similarly, if you want to specify a certificate, define EMITTER_TLS_CERTIFICATE environment variable. Example of configuration file:

{
    "listen": ":8080",
    "license": "/*The license*/",
    "tls": {
        "listen": ":443",
        "host": "example.com"
    },
    "cluster": {
        "listen": ":4000",
        "seed": " 192.168.0.2:4000",
        "advertise": "public:4000"
    },
    "storage": {
        "provider": "inmemory"
    }
}

The structure of the configuration is described below:

PropertyEnv. VariableDescription
licenseEMITTER_LICENSEThe license file to use for the broker. This contains the encryption key.
listenEMITTER_LISTENThe API address used for TCP & Websocket communication, in IP:PORT format (e.g: :8080).
limit.messageSizeEMITTER_LIMIT_MESSAGESIZEMaximum message size. Default is 64KB.
tls.listenEMITTER_TLS_LISTENThe API address used for Secure TCP & Websocket communication, in IP:PORT format (e.g: :443).
tls.hostEMITTER_TLS_HOSTThe hostname to whitelist for the certificate.
tls.emailEMITTER_TLS_EMAILThe email account to use for autocert.
vault.addressEMITTER_VAULT_ADDRESSThe Hashicorp Vault address to use to further override configuration.
vault.appEMITTER_VAULT_APPThe Hashicorp Vault application ID to use.
cluster.nameEMITTER_CLUSTER_NAMEThe name of this node. This must be unique in the cluster. If this is not set, Emitter will set it to the external IP address of the running machine.
cluster.listenEMITTER_CLUSTER_LISTENThe IP address and port that is used to bind the inter-node communication network. This is used for the actual binding of the port.
cluster.advertiseEMITTER_CLUSTER_ADVERTISEThe address and port to advertise inter-node communication network. This is used for nat traversal.
cluster.seedEMITTER_CLUSTER_SEEDThe seed address (or a domain name) for cluster join.
cluster.passphraseEMITTER_CLUSTER_PASSPHRASEPassphrase is used to initialize the primary encryption key in a keyring. This key is used for encrypting all the gossip messages (message-level encryption).
storage.providerEMITTER_STORAGE_PROVIDERThis property represents the publishers publish message storage mode. there are two kinds of can use, they are respectively inmemory and ssd, defaults to the former.
storage.config.dirEMITTER_STORAGE_CONFIGIf the storage mode is ssd, this property indicates where the messages are stored (emitter server nodes are not allowed to use the same directory within the same machine)

Building and Testing

The server requires Golang 1.9 to be installed. Once you have this installed, simply go get this repository and run the following commands to download the package and run the server.

go get -u github.com/emitter-io/emitter && emitter

If you want to run the tests, simply run go test command as demonstrated below.

go test ./...

Deploying as Docker Container

Docker Automated build Docker Pulls

Emitter is conveniently packaged as a docker container. To run the emitter service on a single server, use the command below. Once the server is started, it will generate a new security configuration, you can then re-run the same command with an additional environment variable -e EMITTER_LICENSE set to the provided value.

docker run -d -p 8080:8080 emitter/server

For the clustered (multi-server) mode, the container can be started using the simple docker run with 3 main parameters.

docker run -d -p 8080:8080 -p 4000:4000 -e EMITTER_LICENSE=[key] -e EMITTER_CLUSTER_SEED=[seed] -e EMITTER_CLUSTER_PASSPHRASE=[name] emitter/server

Support, Discussion, and Community

Join the chat at https://gitter.im/emitter-io/public

If you need any help with Emitter Server or any of our client SDKs, please join us at either our gitter chat where most of our team hangs out at or drop us an e-mail at info@emitter.io.

Please submit any Emitter bugs, issues, and feature requests to emitter-io>emitter. If there are any security issues, please email info@emitter.io instead of posting an open issue in Github.

Contributing

If you'd like to contribute, please fork the repository and use a feature branch. Pull requests are warmly welcome.

Licensing

Copyright (c) 2009-2019 Misakai Ltd. This project is licensed under Affero General Public License v3.

Emitter offers support contracts and is now also offered via a commercial license. Please contact info@emitter.io for more information.

NPM DownloadsLast 30 Days