Skip to content
This repository was archived by the owner on Feb 24, 2026. It is now read-only.

Commit 6b7b297

Browse files
author
Alfreedom
authored
Merge pull request #298 from WalletConnect/chores/reconnect_on_timeout
Reconnect relay on timeout
2 parents a9420cf + 86da929 commit 6b7b297

5 files changed

Lines changed: 23 additions & 30 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
## 2.3.0-beta04
1+
## 2.3.0-beta05
22

33
- One-Click Auth support
4-
- Bug fixes
4+
- Bug fixes and improvements
55

66
## 2.2.3
77

example/dapp/lib/main.dart

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -146,23 +146,8 @@ class _MyHomePageState extends State<MyHomePage> {
146146
void _setState(dynamic args) => setState(() {});
147147

148148
void _relayClientError(ErrorEvent? event) {
149-
showDialog(
150-
context: context,
151-
builder: (BuildContext context) {
152-
return AlertDialog(
153-
content: Text(event?.error.toString() ?? 'Relay Client error'),
154-
actions: [
155-
TextButton(
156-
onPressed: () {
157-
_web3App!.core.relayClient.connect();
158-
Navigator.of(context).pop();
159-
},
160-
child: const Text('RETRY'),
161-
),
162-
],
163-
);
164-
},
165-
);
149+
debugPrint('[SampleDapp] _relayClientError ${event?.error}');
150+
_setState('');
166151
}
167152

168153
@override
@@ -220,6 +205,16 @@ class _MyHomePageState extends State<MyHomePage> {
220205
return Scaffold(
221206
appBar: AppBar(
222207
title: Text(_pageDatas[_selectedIndex].title),
208+
centerTitle: true,
209+
actions: [
210+
CircleAvatar(
211+
radius: 6.0,
212+
backgroundColor: _web3App!.core.relayClient.isConnected
213+
? Colors.green
214+
: Colors.red,
215+
),
216+
const SizedBox(width: 16.0),
217+
],
223218
),
224219
bottomNavigationBar:
225220
MediaQuery.of(context).size.width < Constants.smallScreen

lib/apis/core/relay_client/relay_client.dart

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ class RelayClient implements IRelayClient {
210210
core.logger.d('[$runtimeType] Connect timeout: $e');
211211
onRelayClientError.broadcast(ErrorEvent('Connection to relay timeout'));
212212
_connecting = false;
213+
_connect();
213214
} catch (e) {
214215
core.logger.d('[$runtimeType] Connect error: $e');
215216
onRelayClientError.broadcast(ErrorEvent(e));
@@ -310,23 +311,20 @@ class RelayClient implements IRelayClient {
310311
}
311312

312313
// If the code requires reconnect, do so
314+
final reconnectCodes = [1001, 4008, 4010, 1002, 1005, 10002];
313315
if (code != null) {
314-
if (code == 1001 ||
315-
code == 4008 ||
316-
code == 4010 ||
317-
code == 1002 ||
318-
code == 10002 ||
319-
code == 1005) {
316+
if (reconnectCodes.contains(code)) {
320317
await connect();
321318
} else {
322319
await disconnect();
323320
final errorReason = code == 3000
324321
? reason ?? WebSocketErrors.INVALID_PROJECT_ID_OR_JWT
325322
: '';
326323
onRelayClientError.broadcast(
327-
ErrorEvent(
328-
WalletConnectError(code: code, message: errorReason),
329-
),
324+
ErrorEvent(WalletConnectError(
325+
code: code,
326+
message: errorReason,
327+
)),
330328
);
331329
}
332330
}

lib/src/version.dart

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: walletconnect_flutter_v2
22
description: WalletConnect's official Dart library v2 for WalletKit and AppKit. The communications protocol for web3.
3-
version: 2.3.0-beta04
3+
version: 2.3.0-beta05
44
repository: https://github.com/WalletConnect/WalletConnectFlutterV2
55

66
environment:

0 commit comments

Comments
 (0)