All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- Fixed callback return types to include
{:noreply, new_socket}
and{:noreply, new_socket, _rest}
(for returning timeouts or triggeringhandle_continue/2
for example). These return types were always supported but not declared in the callback, so the dialyzer would complain if these values were returned.c:Slipstream.handle_connect/1
c:Slipstream.handle_disconnect/2
c:Slipstream.handle_join/3
c:Slipstream.handle_message/4
c:Slipstream.handle_reply/3
c:Slipstream.handle_topic_close/3
c:Slipstream.handle_leave/2
- Clarified and enhanced
Slipstream.push/4
docs - Clarified and enhanced
Slipstream
module docs around retries
- Fixed a type error on Elixir 1.17+ about an unknown
.message
key.
- Added deserialization clauses to the default (de)serializer for binary
broadcast messages.
- Broadcasts like
MyAppWeb.Endpoint.broadcast!(topic, event, {:binary, <<1, 2, 3>>})
improperly arrived as a message inc:Slipstream.handle_info/2
prior to this fix.
- Broadcasts like
- Added configuration for a serializer module with the default module
implementing
Phoenix.Socket.V2.JSONSerializer
(Phoenix's default serializer). - Added support for sending and receiving binary data.
- The
:json_parser
key previously required a module that exportedencode!/1
anddecode/1
. This key now requires a module that implementsencode!/1
anddecode!/1
.- This was previously documented as requiring
encode/1
but this was a typo in the documentation. - Note that many popular JSON parser/generator libraries share
these function signatures (
encode/1
,encode!/1
,decode/1
anddecode!/1
), so it is unlikely that you will need to make any changes in your code.
- This was previously documented as requiring
- Added the
join_ref
to thephx_leave
message.- This fixes compatibility with Phoenix 1.6.16+ when using
Slipstream.leave/2
.
- This fixes compatibility with Phoenix 1.6.16+ when using
nimble_options
is now allowed at~> 1.0 or ~> 0.1
.- NimbleOptions' v1.0.0 release contains no breaking changes from the 0.x release series.
- Fixed a memory growth issue that could occur when a socket failed to join a
channel repeatedly.
- Memory usage of the Slipstream.Connection process and the client process could grow sharply as the socket tried to rejoin the failed topic, with higher memory usage per retry and per unjoined topic.
- Any
Mint.TransportError
s received will now close the WebSocket connection
This release represents stability in the API. There are no functional changes between this release and v0.8.5.
- Widened compatibility with
mint_web_socket
to~> 1.0
or~> 0.2
- Fixed compatibility with
mint_web_socket
v0.2.0
- Fixed connection closing when
Mint.HTTP.stream/2
returns errors- #42 thanks
@parallel588
!
- #42 thanks
- Properly emit the channel-closed event when
Mint.HTTP.stream/2
returns an error tuple about the connection being closed
- Switched out
:gun
for Mint.WebSocket as the low-level websocket client
- Removed the
:gun_open_options
key from configuration- Use the new
:mint_opts
key instead to configure TLS options
- Use the new
- Added the
:mint_opts
key to configuration for controlling the options passed toMint.HTTP.connect/4
- Added the
:extensions
key to configuration for specifyingMint.WebSocket.Extension
configuration passed toMint.WebSocket.upgrade/4
- Added
c:Slipstream.handle_leave/2
- This is invoked when the server acknowledges that the client has left the topic
- This was previously invoked as the more generic
c:Slipstream.handle_topic_close/3
- Topic leaves are now handled not in
c:Slipstream.handle_topic_close/3
butc:Slipstream.handle_leave/2
- this is a breaking change
In order to migrate existing code, change any implementations of
c:Slipstream.handle_topic_close/3
with the reason
of :left
from
def handle_topic_close(_topic, :left, socket)
To
def handle_leave(_topic, socket)
Note that this callback has a default behavior of performing a no-op.
- Failures to connect (via an
:error
return fromc:Phoenix.Socket.connect/3
) now correctly trigger aSlipstream.Events.ChannelConnectFailed
event- when using the synchronous API, this will result in an error tuple with
Slipstream.await_connect/2
in the format of{:error, {:connect_failure, %{resp_headers: resp_headers, status_code: status_code}}}
wherestatus_code
will be403
. - when using the module-based API, this will invoke the
c:Slipstream.handle_disconnect/2
callback with the same error tuple
- when using the synchronous API, this will result in an error tuple with
await_join!/2
andawait_leave!/2
have been changed toawait_join!/3
andawait_leave!/3
matching their intended usage- the
topic
parameter has been added which coincides with the API ofawait_join/3
andawait_leave/3
- the
- Fixed dialyzer warnings arising from some code macro-injected by
Slipstream.__using__/1
- thanks
@jjcarstens
!
- thanks
- Removed dependency on Phoenix
- Slipstream will now gracefully handle failures from
:gun.open/3
- errors will result in an invocation of a client's
c:Slipstream.handle_disconnect/2
callback (if the client is a module) or return an error tuple fromawait_connect/2
in the case of a synchronous client
- errors will result in an invocation of a client's
- Synchronous functions are now grouped under "Synchronous Functions" in the documentation
- The timer reference for the heartbeat interval is now properly matched upon
in the connection process
- this fixes some behavior where the timer reference would not be canceled
(with
:timer.cancel/1
) upon disconnection - this has not manifested itself as a bug as far as we are aware, but this fix should properly clean up the timer when it is no longer needed
- this fixes some behavior where the timer reference would not be canceled
(with
- Added an example guide on how to use GenServer operations for a client
- Added an example on using Slipstream to script interactions with remote
Phoenix.Channel
s
- Added
Slipstream.Socket.update/3
which emulatesPhoenix.LiveView.update/3
- Added an example on the rejoin-after-reconnect pattern for clients which dynamically join topics
- Link to post-cutover-metrics image made absolute
- Added examples to the documentation
- "Graceful Startup" and "Repeater-style Client"
- Added a note about post-cutover performance changes after we (NFIBrokerage)
cutover to Slipstream in our stack
- This is a new section in the "Why :gun?" guide
- Added documentation on counting the number of Slipstream connection processes
to
Slipstream.ConnectionSupervisor
- Added channel config to socket on
Slipstream.connect/2
orSlipstream.connect!/2
- this fixes an issue reconnecting when faking a connection through
Slipstream.SocketTest.accept_connect/1
- this fixes an issue reconnecting when faking a connection through
- Changed the default behavior of
c:Slipstream.terminate/2
to disconnect gracefully withSlipstream.disconnect/1
- Added better documentation on the
c:Slipstream.terminate/2
callback and how to disconnect in it to leave a connection gracefully
- Added telemetry support for clients
- see the telemetry guide for more details
- Fixed spelling and grammar mistakes in the implementation guide
- increased documentation around retry mechanisms
- added a page on the choice of
:gun
as the low-level webscket client
- Fixed edge case where the remote server shutting down would not emit a
ChannelClosed
event- this and heartbeats caused the odd
:gun_error
atom from #12
- this and heartbeats caused the odd
- The telemetry event for message handles in the connection process should now
correctly publish the
:events
key, not the:event
key - The telemetry guide now correctly states that the
:start_state
key holds the connection state for handle-style events
- Published the connection state at the end of the message handle for
handle-type telemetry events in the connection process
- this is published in the
:end_state
key
- this is published in the
:telemetry
events are executed for each message handled by theSlipstream.Connection
process- this should aide in debugging in scenarios in which one wants to see the full event history of a connection
- Emit
ChannelClosed
event on HTTP close from remote websocket server- See #11
- docs: the main page now shows the
Slipstream
module- frankly, I just want people to see the Basic Usage section as soon as possible so they get a taste for the library
- The connection now properly disconnects when the server's heartbeat replies
timeout with requests
- disconnects for this reason will send have
:heartbeat_timeout
as the reason referenced inc:Slipstream.handle_disconnect/2
- disconnects for this reason will send have
- Connection now correctly emits ChannelClosed events for
:gun
events which occur when a service's network access is terminated
- Added a testing framework
Slipstream.SocketTest
- Published license to hex
- Widened dependency on
:gun
from~> 1.3
to~> 1.0
- as far as I can tell, there aren't any real changes to the websocket interface, so any of these versions should be OK
- More documentation
- including a Basic Usage section with a minimalistic example
- Removed direct dependency on
:telemetry
- see #4
- Initial implementation and initial publish
- This project was generated by Gaas