Important v2.0 Change
tl;dr
The TCP/TLS server/client default packet format has changed in v2.0, causing backwards incompatibility.
If your existing servers/clients are working fine in line_packet mode, there is no need to change to the new packet format.
However, if you wish to upgrade existing servers/clients to v2.0 safely, you must now pass the line_packet: true option.
Here are some examples of adding the option for both server and client:
# Server option should be added to `opts`
JSONRPC2.Servers.TCP.start_listener(handler, port, name: name, line_packet: true)
JSONRPC2.Servers.TCP.child_spec(handler, port, name: name, line_packet: true)
# Client option should be added to `client_opts`
JSONRPC2.Clients.TCP.start(host, port, name, line_packet: true)Why?
The line-terminated packet format caused the size of the packet to be limited by the size of the socket's receive buffer, causing difficult to diagnose errors when the packet size passed the limit.
The only downside of the new approach is a 4-byte overhead due to a new header indicating the size of the rest of the packet.
In light of the fact that the smallest possible JSON-RPC 2.0 request is approximately 50 bytes, I have decided to make this format the new default in an attempt to follow the principle of least surprise.
What if I want to switch to the new packet format, and uptime is a concern?
Here's an example approach:
- Update to v2.0, add
line_packet: true, and deploy. - Add a new server listener for each existing one, on a different port, without
line_packet: true, and deploy. - Update clients to use the new port, remove
line_packet: true, and deploy. - Remove the original server listener for each one you created, and deploy.
Other Changes
- Fixes to Cowboy child_spec
- Documentation fixes
- Dialyzer fixes
Thanks
Thanks to everyone who has contributed to the project!
@naps62, @whitered, @sashman, @ryanleecode, @nkmanolovsumup, @gabrielgiordan, @fredericandre, @pdobacz, and @dkataskin