You can setup Rails ActionCable to use Postgres instead of Redis by adjusting the adapter configuration:
# config/cable.yml
production:
adapter: postgresql
url: <%= ENV["DATABASE_URL"] %>
channel_prefix: myapp_production
This uses the Postgres LISTEN
and NOTIFY
commands.
As of writing, the NOTIFY
payload is limited to 8000 bytes per default. If you're using Hotwire this may not always be enough and you will see error messages like this
PG::InvalidParameterValue (ERROR: payload string too long)
The solutions available to you are the following:
- Configure Postgres for larger payloads (not possible on Heroku)
- Use a fallback strategy for larger payloads as implemented in the actioncable-enhanced-postgresql-adapter gem.
- Use Redis instead (with its own limits)
Top comments (0)