ws 2.0.0-dev.2
ws: ^2.0.0-dev.2 copied to clipboard
WS: A compact, highly efficient WebSocket library. Easily establish, manage, and reconnect WebSocket connections in real-time apps.
2.0.0-dev.2 #
ws_flutteris not published: the name belongs to another package on pub.dev. Do not addws_flutteras the 2.0.0-dev.1 README said; the app lifecycle handling (WebSocketLifecycle) is now a recipe in the README, "Flutter app lifecycle".- README: a pre-release warning, install instructions, recipes (Flutter
app lifecycle, tokens and authentication, resubscribing after a
reconnect, connection status in the UI, binary messages) and a
performance comparison with
web_socket_channel. ws_nativemust have the same version asws: usews_native2.0.0-dev.2 with this release.
2.0.0-dev.1 #
- BREAKING: complete rewrite. New API:
WebSocketClient.binary(),.json(),.text()withpush,rpc,ping,connect,reconnect,disconnect,close; sealed states and exceptions; plain-data options withvm/jsparts. - New pure-Dart RFC 6455 transport on
RawSocket(nodart:ioWebSocket), browser transport onpackage:web(dart2js and dart2wasm). - Reconnect with exponential backoff (jitter above a floor) and terminal-failure detection, heartbeat, request/response correlation, metrics.
- Dead connections are detected by default: heartbeat on (30 s idle,
10 s to answer; a draining upload extends the wait) and TCP keepalive
(
WebSocketVmOptions.keepAlive, 30 s;TCP_USER_TIMEOUTon Linux and Android). WebSocketConnectionException.failure(dns,refused,unreachable,tls,proxy,lost,other),.tls(untrusted,hostname,expired,notYetValid,revoked,handshake) and.proxyStatus. Rejected certificates are retried at the maximum reconnect delay; a proxy 407 stops reconnecting.suspend()andresume()for the app lifecycle: no heartbeat and no reconnects while suspended (an open connection stays open, or is closed withsuspend(disconnect: true));resume()checks the connection with one ping and replaces a dead one at once, without the backoff. Also for network changes. New stateWebSocketState.suspended. Thews_flutterpackage calls them from the Flutter app lifecycle.WebSocketTls.pins(SHA-256 of the server key, leaf only, checked after the chain; mismatch:WebSocketTlsFailure.pinMismatch) andWebSocketTls.trustUserCertificates(Android: also trust user and MDM CAs). On Android both transports drop the system CAs the user disabled. TLS settings are built once per distinct value and reused.WebSocketState.open.urlis the URL the request provider returned; statetoString()no longer prints credentials or the query. RPC deadlines use a monotonic clock, and a burst of calls is linear (32 000 calls: 1.9 s → 25 ms).- Closing: the client lets the server close TCP first (FIN, then up to
1 s), so a server still sending never loses our close frame; long close
reasons are cut at a character boundary. Handshake:
103 Early Hintsis skipped, responses are parsed strictly, non-ASCII host names are refused on the VM (use punycode). Faster UTF-8 validation of non-Latin text (up to 2x). - After
close()every transport refuses sends and pings the same way. An explicitAuthorizationheader wins over URL user info (one header is sent). A throwing transport listener loses no messages. - Web:
maxMessageSizeis enforced (1009, the message is not delivered); a dropped connection reports no close code, like the other transports; an invalid close code from the server is a protocol violation (1002). package:ws/testing.dart: in-memoryFakeWebSocketServerfor tests.package:ws/native.dart: the Rust transport loaded from a file (WsNativeLibrary.open(path).install()), anddart run ws:installto download the released library with a SHA-256 check, for executables built withdart compile exe; it prints where the libraries' third-party notices are. Flutter anddart build cliapps use thews_nativepackage instead, which bundles the library through a build hook.
Removed or changed from 1.x #
WebSocketClient([options])andWebSocketClient.connect(url)are replaced byWebSocketClient.text(),.binary()and.json()(one codec per client);add(data)bypush(data).- Interceptors (
WSInterceptor) are gone; a codec oronMessagecovers them. WebSocketOptions.common(...),.vm(...),.js(...)and the platform option classes are one plain-dataWebSocketOptionswithvmandjsparts.ConnectionManagerand its metrics are gone;client.metricsreplaces them.- The fake client (
ws_client_fake.dart) isFakeWebSocketServerinpackage:ws/testing.dart, a transport rather than a client. - New, not in 1.x:
rpc(), an HTTPCONNECTproxy (WebSocketVmOptions.proxy), TLS options (WebSocketTls: extra roots, pins, user CAs,allowInsecure) and a send limit (sendBufferLimit).
Fixed from 1.x #
- A connect attempt that timed out kept its socket, and a hanging
reconnect stayed in
connectingfor good (#24). Each attempt now owns its socket at every stage (TCP, TLS, HTTP upgrade); the timeout,close()and the next attempt close it. - A dead connection that sends no FIN or RST is detected: the heartbeat
is on by default and uses protocol pings on native platforms (#25,
#26);
ws_flutterre-checks the connection on resume and, given a connectivity stream, on network changes. - An exception from user code on the send path fails that
push()and never reaches the zone (1.xWSInterceptor.wrap). package:web^1.1.0 (#23); messages arrive under dart2wasm, which CI tests in Chrome (#19).
1.1.0-dev.1 #
- Migration from 'dart:html' to 'package:web'
1.0.0 #
- Stable release
- Add interceptors for incoming and outgoing messages
- Add possibility to send messages right after connection
1.0.0-pre.6 #
- BREAKING CHANGE: Change options to separate, platform-specific object
- You can now pass headers and other options to the IO web socket client
- Backoff full jitter strategy for reconnection attempts
- Add more metrics
- Public Fake WebSocket client for testing
0.1.2 #
- Update README.md
0.1.0 #
- Initial release