Skip to content

Commit

Permalink
fix(realtime): Lower heartbeat interval to 25s (#1119)
Browse files Browse the repository at this point in the history
  • Loading branch information
grdsdev authored Feb 18, 2025
1 parent 6976fae commit f58ed2c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
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

0 comments on commit f58ed2c

Please sign in to comment.