Skip to content

Repository files navigation

Ably Pub/Sub Ruby SDK

Ably Pub/Sub Ruby HeaderGem VersionCoverage StatusLicense


Build any realtime experience using Ably’s Pub/Sub Ruby SDK, Supported on all popular platforms and frameworks.

Ably Pub/Sub provides flexible APIs that deliver features such as pub-sub messaging, message history, presence, and push notifications. Utilizing Ably’s realtime messaging platform, applications benefit from its highly performant, reliable, and scalable infrastructure.

Find out more:


Getting started

Everything you need to get started with Ably:


Supported platforms

Ably aims to support a wide range of platforms and browsers. If you experience any compatibility issues, open an issue in the repository or contact Ably support.

PlatformSupport
Ruby>= 2.7 and 3.x. For EventMachine compatibility with Ruby 3.x
EventMachineRequired for using the Realtime API. Compatible with Ruby 3.x with OpenSSL configuration.
libcurlRequired since v1.1.5. On Debian-based systems, install via sudo apt-get install libcurl4.

Important

SDK versions < 1.2.5 will be deprecated from November 1, 2025.


Installation

To get started with your project, install the package:

# Create a new Gemfileecho"source 'https://rubygems.org'"> Gemfile
echo"gem 'ably'">> Gemfile
# Install the gem
bundle install

Note

Install Ruby version 2.7 or greater.


EventMachine

To use the Ably Realtime SDK in Ruby, the EventMachine reactor loop must be running. This is required because the Realtime library depends on EventMachine to handle asynchronous events.

Wrap your code inside a EventMachine.run block:

require'ably'EventMachine.rundoclient=Ably::Realtime.new(key: 'your-api-key')client.connection.connectdoputs"Connected with connection ID: #{client.connection.id}"end

Usage

The following code connects to Ably's realtime messaging service, subscribes to a channel to receive messages, and publishes a test message to that same channel.

# Initialize Ably Realtime clientrealtime_client=Ably::Realtime.new(key: 'your-ably-api-key',client_id: 'me')# Wait for connection to be establishedrealtime_client.connection.on(:connected)doputs'Connected to Ably'# Get a reference to the 'test-channel' channelchannel=realtime_client.channels.get('test-channel')# Subscribe to all messages published to this channelchannel.subscribedo |message|
puts"Received message: #{message.data}"end# Publish a test message to the channelchannel.publish'test-event','hello world'endend

Releases

The CHANGELOG.md contains details of the latest releases for this SDK. You can also view all Ably releases on changelog.ably.com.


Contributing

Read the CONTRIBUTING.md guidelines to contribute to Ably.


Support, feedback and troubleshooting

For help or technical support, visit Ably's support page. You can also view the community reported Github issues or raise one yourself.

About

Ruby client library SDK for Ably realtime messaging service

Topics

Resources

Contributing

Stars

42 stars

Watchers

23 watching

Forks

Releases

Used by

Contributors

Languages