Skip to content

fix(realtime): Lower heartbeat interval to 25s #1119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/realtime_client/lib/src/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:realtime_client/src/version.dart';
class Constants {
static const String vsn = '1.0.0';
static const Duration defaultTimeout = Duration(milliseconds: 10000);
static const int defaultHeartbeatIntervalMs = 25000;
static const int wsCloseNormal = 1000;
static const Map<String, String> defaultHeaders = {
'X-Client-Info': 'realtime-dart/$version',
Expand Down
4 changes: 2 additions & 2 deletions packages/realtime_client/lib/src/realtime_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class RealtimeClient {
final WebSocketTransport transport;
final Client? httpClient;
final _log = Logger('supabase.realtime');
int heartbeatIntervalMs = 30000;
int heartbeatIntervalMs = Constants.defaultHeartbeatIntervalMs;
Timer? heartbeatTimer;

/// reference ID of the most recently sent heartbeat.
Expand Down Expand Up @@ -122,7 +122,7 @@ class RealtimeClient {
String endPoint, {
WebSocketTransport? transport,
this.timeout = Constants.defaultTimeout,
this.heartbeatIntervalMs = 30000,
this.heartbeatIntervalMs = Constants.defaultHeartbeatIntervalMs,
this.logger,
RealtimeEncode? encode,
RealtimeDecode? decode,
Expand Down
2 changes: 1 addition & 1 deletion packages/realtime_client/test/socket_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ void main() {
});
expect(socket.timeout, const Duration(milliseconds: 10000));
expect(socket.longpollerTimeout, 20000);
expect(socket.heartbeatIntervalMs, 30000);
expect(socket.heartbeatIntervalMs, Constants.defaultHeartbeatIntervalMs);
expect(
socket.logger is void Function(
String? kind,
Expand Down