Packages

Phoenix Channels client. Support JSON/TOON/BTOON format.

Current section

Files

Jump to
channel_client CHANGELOG.md
Raw

CHANGELOG.md

# ChannelClient
## v0.12.0
* Breaking changes
* The project is renamed from `phoenix_client` to `channel_client`. All
modules move from `PhoenixClient.*` to `ChannelClient.*` and the mix
dependency/app becomes `:channel_client`.
* Requires Elixir `~> 1.11`.
* Enhancements
* Pluggable wire formats via the `ChannelClient.Format` behaviour: a
single format module owns frame structure and encoding. Ships
`ChannelClient.Formats.JSON` (v1/v2 + any JSON library, the default)
and `ChannelClient.Formats.ETF` (Erlang External Term Format, decoded
in safe mode). Custom formats such as MessagePack plug in with
`format: {MyModule, opts}`; legacy `:vsn` / `:json_library` /
`:serializer` options keep working. See `guides/formats.md`.
* Built-in TOON & BTOON formats (`format: :toon` / `:btoon`) delegating
to a swappable codec library (default modules `Toon` / `BToon`, e.g.
from the `toon_ex` package — not a hard dependency; validated at
startup with guidance when missing).
* Telemetry & tracing support: `:telemetry` events for connection
attempts (`start`/`stop` spans), decoded and queued messages (with
payload byte sizes), disconnects, channel joins and synchronous pushes
(`start`/`stop`/`exception` span triples). See
`ChannelClient.Telemetry` and `guides/telemetry.md`.
* Pluggable message middleware, modelled after Phoenix's Plug behaviour.
Sockets accept `:inbound_plugs` and `:outbound_plugs`; plugs transform
or halt messages via `{:cont, msg} | {:halt, reason}` results, with
module and function plug support. Ships `ChannelClient.Plug`,
`ChannelClient.Plugs.Logger` and `ChannelClient.Plugs.FilterEvents`.
See `guides/plugs.md`.
* Support `:binary` WebSocket frames: frames received as binary are decoded
through the configured JSON library just like text frames.
* Outbound frames are encoded eagerly in the caller's process and buffered
pre-encoded, keeping serialization work off the socket process.
* Replace the per-push flush scheduling with a single pending-flush flag;
buffered frames are drained once on reconnect instead of polling every
100ms while idle.
* Socket options are validated at startup with descriptive
`ArgumentError`s (URL scheme/host, JSON library, protocol version).
`:serializer` is accepted as an alias for `:json_library`.
* Documented options on `ChannelClient.Socket`.
* Bug fixes
* Fix protocol v2 framing: join frames now carry their own ref as
`join_ref`, and push/leave frames carry the topic's join ref. Phoenix
servers silently drop non-join frames whose `join_ref` does not match,
which made pushes and leaves no-ops against modern servers.
* Malformed inbound frames are logged and dropped instead of crashing the
socket process.
* Unencodable payloads return `{:error, reason}` to sync callers and are
logged and dropped for async pushes, instead of crashing the socket.
* Reply statuses are mapped through a safe whitelist (`ok`, `error`,
`timeout`) instead of dynamically creating atoms from server data.
* Malformed `phx_reply` payloads resolve as errors instead of crashing the
channel.
* `ChannelClient.Channel.leave/1` and `stop/1` are idempotent and safe to
call on already-dead channels.
* `ChannelClient.Socket.connected?/1` returns `false` for dead or missing
sockets instead of crashing the caller.
* Stale transport notifications (from a previous connection process) are
ignored instead of crashing the socket.
* Test suite raised to ~93% coverage; the test dependency stack now uses
hex packages (`phoenix ~> 1.7`) that compile on modern OTP releases.
## v0.11.1
* Enhancements
* Remove delay when sending messages through the socket.
## v0.11.0
* Enhancements
* `websocket_client` is no longer an optional dependency.
* Delegate heartbeat to the transport instead of using the `phx_heartbeat`
message. This results in a much smaller payload for keeping the connection
alive.
* Add `:ssl` to extra_applications so it is included and started with OTP.
## v0.10.0
* Enhancements
* Extra headers can be added to the initial socket connection through the
`socket_opts` using the key `headers: [{"header-name", "value"}]`
## v0.9.0
* Enhancements
* All out of band reply messages are delivered to the channel's caller
as broadcast messages. This allows the use of `push_async` to send
messages to the server that may `:reply` in an indeterminate amount of time.
## v0.8.0
* Enhancements
* Add support for v1 and v2 phoenix channel message protocol.
* Bug fixes
* Remove the channels from the socket when disconnecting.
* Merge query params from original url when constructing new connection
url.
## v0.7.0
* Enhancements
* Update to use the Phoenix message protocol version 2.0.0
* Improved socket disconnect handling
## v0.6.1
* Enhancements
* Do not exit if a call to join results in a timeout. Instead, return
{:error, :timeout}.
## v0.6.0
* Enhancements
* Removed `Socket.status/1` in favor of `Socket.connected?/1`.
* Channel.start_link and stop are now private. You should call
Channel.join/leave to manage the lifecycle of the channel connection.
* Added a DynamicSupervisor for Channel connections
* Bug fixes
* Refactored socket channel leaves and joins. The socket is now responsible
for sending the join and leave messages. This fixes potential issues where
the socket could attempt to join a topic more than once.
## v0.5.1
* Bug fixes
* Attempt to reconnect the socket if transport exits abnormally.
* Prevent the channel from delivering multiple "phx_error" or "phx_close".
messages if the socket fails.
* Set the socket status to :disconnected when the transport exits.
## v0.5.0
**Important**
This version has been renamed and refactored. You will need to migrate existing
`phoenix_channel_client` projects before first use. Please see the readme for
how to implement this new pattern.
* Bug fixes
* The Socket will monitor linked channels for down messages and remove them
from the channel links.
* Enhancements
* Removed the requirement to define `Socket` and `Channel` modules that implement
their respective behaviours. Sockets are now started by calling
`PhoenixClient.Socket.start_link` directly.
Channels are started by calling `PhoenixClient.Channel`.
* Calls to `PhoenixClient.Channel.push` happen synchronously. This helps to
reduce callback spaghetti code by making the reply available at the call site.
If you do not require a response from the server, you can use `push_async`.
* Non-reply messages that are pushed from the server will be sent to the pid
of the process that called join. They will be delivered as `%PhoenixClient.Message{}`.
See the main readme for an example of this.
## v0.4.0
* Breaking changes
* Channel pids are not longer named by default. If you would like to name the
pid, you can pass genserver_opts to the child spec:
For example:
```elixir
{MyApp.Channel, {[socket: MyApp.Socket, topic: "room:lobby"], [name: MyApp.Channel]}}
```
* Calls for `join`, `push`, `cancel_push`, and `leave` are no longer injected
into the channel module. These functions have been moved to the
`PhoenixClient` module.
For example:
```elixir
MyChannel.join()
# becomes
PhoenixClient.join(channel_pid_or_name)
```
## v0.3.2
* Bug fixes
* Fix issue with rejoin timer being fired before initial join.
## v0.3.1
* Bug fixes
* Fix issue with socket spawning too many adaptors on reconnect timer.
## v0.3.0
* Enhancements
* Pass `handle_info/2`, `handle_call/3`, and `haneld_cast/2` messages
through to the channel server process
* Add ability to pass socket params
* Add support for client SSL certificates
* Use `Jason` as default JSON parser
* Bug Fixes
* Only send heartbeat messages when the channel is connected.
* Quiet logging output
## v0.2.0
* Bug Fixes
* Fixed issues with missing disconnect handlers in websocket code
* Fixed crashes when sending socket closures to channels
* Send adapter open args to websocket
* Enhancements
* Added reconnect timer
## v0.1.0
* Initial Release