the-mikedavis

the-mikedavis

Slipstream - A slick Elixir websocket client for Phoenix Channels

We @ NFIBrokerage use websockets and Phoenix.Channels fairly extensively in production, serving well over 100k connections a week.

When we first started using websockets broadly between back-end services, we noticed an odd build-up of process memory in Phoenix.Channel server processes which we now presume to be a product of moving large amounts of data over-the-wire and a known issue in :websocket_client (see more in the Slipstream documentation). This and the at-the-time archival of the popular phoenix_gen_socket_client led us to write a new Phoenix.Channel client from scratch backed by :gun.

Enter Slipstream!

Slipstream touts

  • :gun under the hood
  • reconnect and rejoin mechanisms with back-off similar to phoenix.js
  • a rich set of :telemetry events
  • utilities for testing clients similar to Phoenix.ChannelTest
  • a GenServer-like callback interface for client modules with default implemementations for all callbacks
  • a synchronous interface for scripting
  • an ever-expanding examples directory with reference clients and tutorials

After cutting over the bulk of our socket clients to Slipstream, we’ve seen a marked decline in clients disconnecting from Phoenix.Channels as a result of the server disconnecting them (as opposed to the client gracefully disconnecting).

(That line at 02/02 13:20 marks the mass cutover. Note that the other disconnection reasons than “disconnected by remote server” are expected and are considered normal and desirable behavior. Remainders of “disconnection by remote server” denote deploys and restarts of services running Phoenix.Channels. Also note that this improvement is more likely an indirect result of switching to :gun: that the remote server has less memory pressure and is therefore more reliable, rather than a hypothetical bug in the :websocket_client implemementation which would force disconnects.)

We’ve been using slipstream widely in production for a little while now and want to share it with y’all! If you’re in the market for a new Phoenix.Channel client, look no further.

Most Liked

the-mikedavis

the-mikedavis

Slipstream v0.8.0 has been released!

v0.8.0 switches out :gun for Mint.WebSocket as the low-level WebSocket client.

Gun is great but its strict dependencies on cowlib often conflict with cowboy’s (and therefore Phoenix), making it hard to use gun in a Phoenix project without an override.

Check out the CHANGELOG for extended notes on the changes and how to upgrade.

10
Post #3
jamesvl

jamesvl

This looks really great! Thanks for open sourcing this; I hope to get some time soon to try it out locally in one of my projects that also relies quite heavily on websockets.

lawik

lawik

Nerves Core Team

Slipstream inplements Phoenix Channels which is a specific implementation on top of WebSockets.

For raw WebSockets you can check what Slipstream depends on over at hex.pm. There should be a websocket library in there.

Where Next?

Popular in Libraries Top

marcuslankenau
I feel kind of stuck with the absence of a proper xml library for Elixir. Currently I use SweetXML which was ok for me more or less to pa...
New
deadtrickster
I’ve just released stable versions of my Prometheus Elixir libs: Elixir client [docs]; Ecto collector [docs]; Plugs instrumenter/Export...
New
archan937
It is a well-know topic within the Elixir community: “To mock or not to mock? :)” Every alchemist probably has his / her own opinion con...
New
dbern
I’m excited to announce that TaxJar has developed and open-sourced DateTimeParser. We developed it because we found a need to parse user ...
New
riverrun
I’ve just released version 3 of Comeonin, a password hashing library. The following small changes have been made: changes to the NIF c...
New
MRdotB
I needed to reuse React components from my Chrome extension in my Phoenix/LiveView backend. I noticed that for Svelte/Vue, there are live...
New
wmnnd
Hi there, for my project DBLSQD, I needed a file storage solution that is a bit more flexible than Arc. Because I thought others might f...
New
bryanjos
Hi, I wanted share a small library we at Revelry Labs made for rendering react components from the server side. There are instructions fo...
New
gjaldon
As the title states, EctoEnum has just been updated after some time of hardly any activity in the repo. Here’s the latest release: https:...
New
mischov
import Meeseeks.CSS html = HTTPoison.get!("https://news.ycombinator.com/").body for story <- Meeseeks.all(html, css("tr.athing")) do...
New

Other popular topics Top

senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
yawaramin
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 45766 226
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New

Sub Categories:

We're in Beta

About us Mission Statement