Thank you so much for explaining Calin Following your advice, I managed to get the Websocket to connect, but somehow the rpcClient isn’t sticking
“Socket disconnected prematurely” is an error given when get rpcSocket turns up an null WebSocket object (see the end of the 2nd chunk of code).
Would you have any idea how to proceed? I’ll sleep over it and try again tomorrow.
Thank you so much already, truly!
Here are the flutter logs:
I/flutter ( 8594): [FINE] JSONRPCWebsocket -- 2021-12-06 22:39:14.741918 -- starting to connect to wss://blackie c3-soft com:60004
I/flutter ( 8594): Exception: Socket disconnected prematurely
I/flutter ( 8594): [FINE] JSONRPCWebsocket -- 2021-12-06 22:39:14.777361 -- starting to connect to wss://bch0 kister net
I/flutter ( 8594): Exception: Socket disconnected prematurely
I/flutter ( 8594): [FINE] JSONRPCWebsocket -- 2021-12-06 22:39:14.798589 -- starting to connect to wss://blackie c3-soft com:60004
I/flutter ( 8594): Exception: Socket disconnected prematurely
I/flutter ( 8594): [SEVERE] Wallet -- 2021-12-06 22:39:24.380052 -- Oh no!
I/flutter ( 8594): [FINE] JSONRPCWebsocket -- 2021-12-06 22:39:27.198612 -- connected to websocket, current state 1
I/flutter ( 8594): [FINE] JSONRPCWebsocket -- 2021-12-06 22:39:27.247353 -- connected to websocket, current state 1
I/flutter ( 8594): [FINE] Wallet -- 2021-12-06 22:40:03.654889 -- Grabbing UTXOs from electrum and then updating balance via vault.
I/flutter ( 8594): [FINE] JSONRPCWebsocket -- 2021-12-06 22:40:03.657014 -- starting to connect to wss://blackie.c3-soft.com:60004
I/flutter ( 8594): Exception: Socket disconnected prematurely
I/flutter ( 8594): [FINE] JSONRPCWebsocket -- 2021-12-06 22:40:03.678117 -- starting to connect to wss://blackie.c3-soft.com:60004
I/flutter ( 8594): Exception: Socket disconnected prematurely
I/flutter ( 8594): [FINE] JSONRPCWebsocket -- 2021-12-06 22:40:03.690499 -- starting to connect to wss://blackie.c3-soft.com:60004
I/flutter ( 8594): Exception: Socket disconnected prematurely
E/flutter ( 8594): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: Exception: Socket disconnected prematurely
E/flutter ( 8594): #0 JSONRPCWebsocket.rpcSocket
E/flutter ( 8594): #1 JSONRPCWebsocket.subscribe
E/flutter ( 8594): #2 ElectrumClient.blockchainScripthashSubscribe
E/flutter ( 8594): #3 Wallet.startUtxoListeners
E/flutter ( 8594): #4 new Wallet.<anonymous closure>
E/flutter ( 8594): #5 ElectrumFactory.getInstance
E/flutter ( 8594): #6 ElectrumFactory.getInstance
E/flutter ( 8594): <asynchronous suspension>
E/flutter ( 8594): #7 ElectrumFactory.getInstance
E/flutter ( 8594): <asynchronous suspension>
E/flutter ( 8594): #8 Wallet.refreshBalanceRemote
E/flutter ( 8594): <asynchronous suspension>
E/flutter ( 8594): #9 _DevToolsPageState.build.<anonymous closure>
E/flutter ( 8594): <asynchronous suspension>
E/flutter ( 8594):
I/flutter ( 8594): [FINE] JSONRPCWebsocket -- 2021-12-06 22:40:04.290134 -- connected to websocket, current state 1
I/flutter ( 8594): [FINE] JSONRPCWebsocket -- 2021-12-06 22:40:04.305716 -- connected to websocket, current state 1
I/flutter ( 8594): [FINE] JSONRPCWebsocket -- 2021-12-06 22:40:04.317505 -- connected to websocket, current state 1
I/flutter ( 8594): [FINE] Wallet -- 2021-12-06 22:40:06.847375 -- Grabbing UTXOs from electrum and then updating balance via vault.
I/flutter ( 8594): [FINE] JSONRPCWebsocket -- 2021-12-06 22:40:06.863767 -- starting to connect to wss://blackie.c3-soft.com:60004
I/flutter ( 8594): Exception: Socket disconnected prematurely
I/flutter ( 8594): [FINE] JSONRPCWebsocket -- 2021-12-06 22:40:06.874963 -- starting to connect to wss://blackie.c3-soft.com:60004
I/flutter ( 8594): Exception: Socket disconnected prematurely
I/flutter ( 8594): [FINE] JSONRPCWebsocket -- 2021-12-06 22:40:06.879812 -- starting to connect to wss://blackie.c3-soft.com:60004
I/flutter ( 8594): Exception: Socket disconnected prematurely
E/flutter ( 8594): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: Exception: Socket disconnected prematurely
E/flutter ( 8594): #0 JSONRPCWebsocket.rpcSocket
E/flutter ( 8594): #1 JSONRPCWebsocket.subscribe
E/flutter ( 8594): #2 ElectrumClient.blockchainScripthashSubscribe
E/flutter ( 8594): #3 Wallet.startUtxoListeners
E/flutter ( 8594): #4 new Wallet.<anonymous closure>
E/flutter ( 8594): #5 ElectrumFactory.getInstance
E/flutter ( 8594): #6 ElectrumFactory.getInstance
E/flutter ( 8594): <asynchronous suspension>
E/flutter ( 8594): #7 ElectrumFactory.getInstance
E/flutter ( 8594): <asynchronous suspension>
E/flutter ( 8594): #8 Wallet.refreshBalanceRemote
E/flutter ( 8594): <asynchronous suspension>
E/flutter ( 8594): #9 _DevToolsPageState.build.<anonymous closure>
E/flutter ( 8594): <asynchronous suspension>
E/flutter ( 8594):
I/flutter ( 8594): [FINE] JSONRPCWebsocket -- 2021-12-06 22:40:07.483055 -- connected to websocket, current state 1
I/flutter ( 8594): [FINE] JSONRPCWebsocket -- 2021-12-06 22:40:07.494254 -- connected to websocket, current state 1
I/flutter ( 8594): [FINE] JSONRPCWebsocket -- 2021-12-06 22:40:07.507279 -- connected to websocket, current state 1
I/flutter ( 8594): ping
E/flutter ( 8594): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: Exception: Socket disconnected prematurely
E/flutter ( 8594): #0 JSONRPCWebsocket.rpcSocket
E/flutter ( 8594): #1 new ElectrumClient.<anonymous closure>
E/flutter ( 8594): #2 _rootRun (dart:async/zone.dart:1420:47)
E/flutter ( 8594): #3 _CustomZone.run (dart:async/zone.dart:1328:19)
E/flutter ( 8594): #4 _CustomZone.runGuarded (dart:async/zone.dart:1236:7)
E/flutter ( 8594): #5 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1276:23)
E/flutter ( 8594): #6 _rootRun (dart:async/zone.dart:1428:13)
E/flutter ( 8594): #7 _CustomZone.run (dart:async/zone.dart:1328:19)
E/flutter ( 8594): #8 _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:1260:23)
E/flutter ( 8594): #9 Timer._createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:18:15)
E/flutter ( 8594): #10 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:395:19)
E/flutter ( 8594): #11 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:426:5)
E/flutter ( 8594): #12 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:187:12)
E/flutter ( 8594):
I/flutter ( 8594): ping
E/flutter ( 8594): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: SocketException: OS Error: Connection refused, errno = 111, address = bch0*kister*net, port = 44204
E/flutter ( 8594): #0 _NativeSocket.startConnect (dart:io-patch/socket_patch.dart:677:35)
E/flutter ( 8594): #1 _RawSocket.startConnect (dart:io-patch/socket_patch.dart:1680:26)
E/flutter ( 8594): #2 RawSocket.startConnect (dart:io-patch/socket_patch.dart:27:23)
E/flutter ( 8594): #3 RawSecureSocket.startConnect (dart:io/secure_socket.dart:237:22)
E/flutter ( 8594): #4 SecureSocket.startConnect (dart:io/secure_socket.dart:60:28)
E/flutter ( 8594): #5 _ConnectionTarget.connect (dart:_http/http_impl.dart:2437:24)
E/flutter ( 8594): #6 _HttpClient._getConnection.connect (dart:_http/http_impl.dart:2805:12)
E/flutter ( 8594): #7 _HttpClient._getConnection (dart:_http/http_impl.dart:2810:12)
E/flutter ( 8594): #8 _HttpClient._openUrl (dart:_http/http_impl.dart:2694:12)
E/flutter ( 8594): #9 _HttpClient.openUrl (dart:_http/http_impl.dart:2568:7)
E/flutter ( 8594): #10 _WebSocketImpl.connect (dart:_http/websocket_impl.dart:1027:24)
E/flutter ( 8594): #11 WebSocket.connect (dart:_http/websocket.dart:379:22)
E/flutter ( 8594): #12 JSONRPCWebsocket.connect
E/flutter ( 8594): #13 ElectrumFactory.getInstance
E/flutter ( 8594): #14 ElectrumFactory.getInstance
E/flutter ( 8594): <asynchronous suspension>
E/flutter ( 8594): #15 Wallet.initialize
E/flutter ( 8594): <asynchronous suspension>
E/flutter ( 8594): #16 WalletModel.initializeModel
E/flutter ( 8594): <asynchronous suspension>
E/flutter ( 8594):
I/flutter ( 8594): ping
I/chatty ( 8594): uid=10133(com.willyounerime.neri) 1.ui identical 1 line
I/flutter ( 8594): ping
E/flutter ( 8594): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: Exception: Socket disconnected prematurely
E/flutter ( 8594): #0 JSONRPCWebsocket.rpcSocket
E/flutter ( 8594): #1 new ElectrumClient.<anonymous closure>
E/flutter ( 8594): #2 _rootRun (dart:async/zone.dart:1420:47)
E/flutter ( 8594): #3 _CustomZone.run (dart:async/zone.dart:1328:19)
E/flutter ( 8594): #4 _CustomZone.runGuarded (dart:async/zone.dart:1236:7)
E/flutter ( 8594): #5 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1276:23)
E/flutter ( 8594): #6 _rootRun (dart:async/zone.dart:1428:13)
E/flutter ( 8594): #7 _CustomZone.run (dart:async/zone.dart:1328:19)
E/flutter ( 8594): #8 _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:1260:23)
E/flutter ( 8594): #9 Timer._createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:18:15)
E/flutter ( 8594): #10 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:395:19)
E/flutter ( 8594): #11 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:426:5)
E/flutter ( 8594): #12 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:187:12)
E/flutter ( 8594):
I/chatty ( 8594): uid=10133(com.willyounerime.neri) 1.ui identical 1 line
E/flutter ( 8594): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: Exception: Socket disconnected prematurely
E/flutter ( 8594): #0 JSONRPCWebsocket.rpcSocket
E/flutter ( 8594): #1 new ElectrumClient.<anonymous closure>
E/flutter ( 8594): #2 _rootRun (dart:async/zone.dart:1420:47)
E/flutter ( 8594): #3 _CustomZone.run (dart:async/zone.dart:1328:19)
E/flutter ( 8594): #4 _CustomZone.runGuarded (dart:async/zone.dart:1236:7)
E/flutter ( 8594): #5 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1276:23)
E/flutter ( 8594): #6 _rootRun (dart:async/zone.dart:1428:13)
E/flutter ( 8594): #7 _CustomZone.run (dart:async/zone.dart:1328:19)
E/flutter ( 8594): #8 _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:1260:23)
E/flutter ( 8594): #9 Timer._createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:18:15)
E/flutter ( 8594): #10 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:395:19)
E/flutter ( 8594): #11 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:426:5)
E/flutter ( 8594): #12 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:187:12)
E/flutter ( 8594):
E/flutter ( 8594): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: Exception: Socket disconnected prematurely
E/flutter ( 8594): #0 JSONRPCWebsocket.rpcSocket
E/flutter ( 8594): #1 new ElectrumClient.<anonymous closure>
E/flutter ( 8594): #2 _rootRun (dart:async/zone.dart:1420:47)
E/flutter ( 8594): #3 _CustomZone.run (dart:async/zone.dart:1328:19)
E/flutter ( 8594): #4 _CustomZone.runGuarded (dart:async/zone.dart:1236:7)
E/flutter ( 8594): #5 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1276:23)
E/flutter ( 8594): #6 _rootRun (dart:async/zone.dart:1428:13)
E/flutter ( 8594): #7 _CustomZone.run (dart:async/zone.dart:1328:19)
E/flutter ( 8594): #8 _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:1260:23)
E/flutter ( 8594): #9 Timer._createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:18:15)
E/flutter ( 8594): #10 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:395:19)
E/flutter ( 8594): #11 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:426:5)
E/flutter ( 8594): #12 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:187:12)
E/flutter ( 8594):
E/flutter ( 8594): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: Exception: Socket disconnected prematurely
E/flutter ( 8594): #0 JSONRPCWebsocket.rpcSocket
E/flutter ( 8594): #1 new ElectrumClient.<anonymous closure>
E/flutter ( 8594): #2 _rootRun (dart:async/zone.dart:1420:47)
E/flutter ( 8594): #3 _CustomZone.run (dart:async/zone.dart:1328:19)
E/flutter ( 8594): #4 _CustomZone.runGuarded (dart:async/zone.dart:1236:7)
E/flutter ( 8594): #5 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1276:23)
E/flutter ( 8594): #6 _rootRun (dart:async/zone.dart:1428:13)
E/flutter ( 8594): #7 _CustomZone.run (dart:async/zone.dart:1328:19)
E/flutter ( 8594): #8 _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:1260:23)
E/flutter ( 8594): #9 Timer._createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:18:15)
E/flutter ( 8594): #10 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:395:19)
E/flutter ( 8594): #11 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:426:5)
E/flutter ( 8594): #12 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:187:12)
E/flutter ( 8594):
I/flutter ( 8594): ping
E/flutter ( 8594): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: SocketException: OS Error: Connection refused, errno = 111, address = bch0*kister*net, port = 44232
E/flutter ( 8594): #0 _NativeSocket.startConnect (dart:io-patch/socket_patch.dart:677:35)
E/flutter ( 8594): #1 _RawSocket.startConnect (dart:io-patch/socket_patch.dart:1680:26)
E/flutter ( 8594): #2 RawSocket.startConnect (dart:io-patch/socket_patch.dart:27:23)
E/flutter ( 8594): #3 RawSecureSocket.startConnect (dart:io/secure_socket.dart:237:22)
E/flutter ( 8594): #4 SecureSocket.startConnect (dart:io/secure_socket.dart:60:28)
E/flutter ( 8594): #5 _ConnectionTarget.connect (dart:_http/http_impl.dart:2437:24)
E/flutter ( 8594): #6 _HttpClient._getConnection.connect (dart:_http/http_impl.dart:2805:12)
E/flutter ( 8594): #7 _HttpClient._getConnection (dart:_http/http_impl.dart:2810:12)
E/flutter ( 8594): #8 _HttpClient._openUrl (dart:_http/http_impl.dart:2694:12)
E/flutter ( 8594): #9 _HttpClient.openUrl (dart:_http/http_impl.dart:2568:7)
E/flutter ( 8594): #10 _WebSocketImpl.connect (dart:_http/websocket_impl.dart:1027:24)
E/flutter ( 8594): #11 WebSocket.connect (dart:_http/websocket.dart:379:22)
E/flutter ( 8594): #12 JSONRPCWebsocket.connect
E/flutter ( 8594): #13 ElectrumFactory.getInstance
E/flutter ( 8594): #14 Wallet.refreshBalanceRemote
E/flutter ( 8594): #15 _DevToolsPageState.build.<anonymous closure>
E/flutter ( 8594): #16 _DevToolsPageState.build.<anonymous closure>
E/flutter ( 8594): #17 _InkResponseState._handleTap
E/flutter ( 8594): #18 GestureRecognizer.invokeCallback
E/flutter ( 8594): #19 TapGestureRecognizer.handleTapUp
E/flutter ( 8594): #20 BaseTapGestureRecognizer._checkUp
E/flutter ( 8594): #21 BaseTapGestureRecognizer.handlePrimaryPointer
E/flutter ( 8594): #22 PrimaryPointerGestureRecognizer.handleEvent
E/flutter ( 8594): #23 PointerRouter._dispatch
E/flutter ( 8594): #24 PointerRouter._dispatchEventToRoutes.<anonymous closure>
E/flutter ( 8594): #25 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:400:8)
E/flutter ( 8594): #26 PointerRouter._dispatchEventToRoutes
E/flutter ( 8594): #27 PointerRouter.route
E/flutter ( 8594): #28 GestureBinding.handleEvent
E/flutter ( 8594): #29 GestureBinding.dispatchEvent
E/flutter ( 8594): #30 RendererBinding.dispatchEvent
E/flutter ( 8594): #31 GestureBinding._handlePointerEventImmediately
E/flutter ( 8594): #32 GestureBinding.handlePointerEvent
E/flutter ( 8594): #33 GestureBinding._flushPointerEventQueue
E/flutter ( 8594): #34 GestureBinding._handlePointerDataPacket
E/flutter ( 8594): #35 _rootRunUnary (dart:async/zone.dart:1444:13)
E/flutter ( 8594): #36 _CustomZone.runUnary (dart:async/zone.dart:1335:19)
E/flutter ( 8594): #37 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1244:7)
E/flutter ( 8594): #38 _invoke1 (dart:ui/hooks.dart:185:10)
E/flutter ( 8594): #39 PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:293:7)
E/flutter ( 8594): #40 _dispatchPointerDataPacket (dart:ui/hooks.dart:98:31)
E/flutter ( 8594):
E/flutter ( 8594): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: SocketException: OS Error: Connection refused, errno = 111, address = bch0*kister*net, port = 44230
E/flutter ( 8594): #0 _NativeSocket.startConnect (dart:io-patch/socket_patch.dart:677:35)
E/flutter ( 8594): #1 _RawSocket.startConnect (dart:io-patch/socket_patch.dart:1680:26)
E/flutter ( 8594): #2 RawSocket.startConnect (dart:io-patch/socket_patch.dart:27:23)
E/flutter ( 8594): #3 RawSecureSocket.startConnect (dart:io/secure_socket.dart:237:22)
E/flutter ( 8594): #4 SecureSocket.startConnect (dart:io/secure_socket.dart:60:28)
E/flutter ( 8594): #5 _ConnectionTarget.connect (dart:_http/http_impl.dart:2437:24)
E/flutter ( 8594): #6 _HttpClient._getConnection.connect (dart:_http/http_impl.dart:2805:12)
E/flutter ( 8594): #7 _HttpClient._getConnection (dart:_http/http_impl.dart:2810:12)
E/flutter ( 8594): #8 _HttpClient._openUrl (dart:_http/http_impl.dart:2694:12)
E/flutter ( 8594): #9 _HttpClient.openUrl (dart:_http/http_impl.dart:2568:7)
E/flutter ( 8594): #10 _WebSocketImpl.connect (dart:_http/websocket_impl.dart:1027:24)
E/flutter ( 8594): #11 WebSocket.connect (dart:_http/websocket.dart:379:22)
E/flutter ( 8594): #12 JSONRPCWebsocket.connect
E/flutter ( 8594): #13 ElectrumFactory.getInstance
E/flutter ( 8594): #14 ElectrumFactory.getInstance
E/flutter ( 8594): <asynchronous suspension>
E/flutter ( 8594): #15 ElectrumFactory.getInstance
E/flutter ( 8594): <asynchronous suspension>
E/flutter ( 8594): #16 Wallet.refreshBalanceRemote
E/flutter ( 8594): <asynchronous suspension>
E/flutter ( 8594): #17 _DevToolsPageState.build.<anonymous closure>
E/flutter ( 8594): <asynchronous suspension>
E/flutter ( 8594):
E/flutter ( 8594): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: SocketException: OS Error: Connection refused, errno = 111, address = bch0*kister*net, port = 44228
E/flutter ( 8594): #0 _NativeSocket.startConnect (dart:io-patch/socket_patch.dart:677:35)
E/flutter ( 8594): #1 _RawSocket.startConnect (dart:io-patch/socket_patch.dart:1680:26)
E/flutter ( 8594): #2 RawSocket.startConnect (dart:io-patch/socket_patch.dart:27:23)
E/flutter ( 8594): #3 RawSecureSocket.startConnect (dart:io/secure_socket.dart:237:22)
E/flutter ( 8594): #4 SecureSocket.startConnect (dart:io/secure_socket.dart:60:28)
E/flutter ( 8594): #5 _ConnectionTarget.connect (dart:_http/http_impl.dart:2437:24)
E/flutter ( 8594): #6 _HttpClient._getConnection.connect (dart:_http/http_impl.dart:2805:12)
E/flutter ( 8594): #7 _HttpClient._getConnection (dart:_http/http_impl.dart:2810:12)
E/flutter ( 8594): #8 _HttpClient._openUrl (dart:_http/http_impl.dart:2694:12)
E/flutter ( 8594): #9 _HttpClient.openUrl (dart:_http/http_impl.dart:2568:7)
E/flutter ( 8594): #10 _WebSocketImpl.connect (dart:_http/websocket_impl.dart:1027:24)
E/flutter ( 8594): #11 WebSocket.connect (dart:_http/websocket.dart:379:22)
E/flutter ( 8594): #12 JSONRPCWebsocket.connect
E/flutter ( 8594): #13 ElectrumFactory.getInstance
E/flutter ( 8594): #14 ElectrumFactory.getInstance
E/flutter ( 8594): <asynchronous suspension>
E/flutter ( 8594): #15 Wallet.refreshBalanceRemote
E/flutter ( 8594): <asynchronous suspension>
E/flutter ( 8594): #16 _DevToolsPageState.build.<anonymous closure>
E/flutter ( 8594): <asynchronous suspension>
E/flutter ( 8594):
I/flutter ( 8594): ping
E/flutter ( 8594): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: Exception: Socket disconnected prematurely
E/flutter ( 8594): #0 JSONRPCWebsocket.rpcSocket
E/flutter ( 8594): #1 new ElectrumClient.<anonymous closure>
E/flutter ( 8594): #2 _rootRun (dart:async/zone.dart:1420:47)
E/flutter ( 8594): #3 _CustomZone.run (dart:async/zone.dart:1328:19)
E/flutter ( 8594): #4 _CustomZone.runGuarded (dart:async/zone.dart:1236:7)
E/flutter ( 8594): #5 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1276:23)
E/flutter ( 8594): #6 _rootRun (dart:async/zone.dart:1428:13)
E/flutter ( 8594): #7 _CustomZone.run (dart:async/zone.dart:1328:19)
E/flutter ( 8594): #8 _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:1260:23)
E/flutter ( 8594): #9 Timer._createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:18:15)
E/flutter ( 8594): #10 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:395:19)
E/flutter ( 8594): #11 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:426:5)
E/flutter ( 8594): #12 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:187:12)
E/flutter ( 8594):
E/flutter ( 8594): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: Exception: Socket disconnected prematurely
E/flutter ( 8594): #0 JSONRPCWebsocket.rpcSocket
E/flutter ( 8594): #1 new ElectrumClient.<anonymous closure>
E/flutter ( 8594): #2 _rootRun (dart:async/zone.dart:1420:47)
E/flutter ( 8594): #3 _CustomZone.run (dart:async/zone.dart:1328:19)
E/flutter ( 8594): #4 _CustomZone.runGuarded (dart:async/zone.dart:1236:7)
E/flutter ( 8594): #5 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1276:23)
E/flutter ( 8594): #6 _rootRun (dart:async/zone.dart:1428:13)
E/flutter ( 8594): #7 _CustomZone.run (dart:async/zone.dart:1328:19)
E/flutter ( 8594): #8 _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:1260:23)
E/flutter ( 8594): #9 Timer._createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:18:15)
E/flutter ( 8594): #10 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:395:19)
E/flutter ( 8594): #11 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:426:5)
E/flutter ( 8594): #12 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:187:12)
E/flutter ( 8594):
I/lyounerime.ner( 8594): NativeAlloc concurrent copying GC freed 7228(349KB) AllocSpace objects, 0(0B) LOS objects, 49% free, 2510KB/5021KB, paused 588us total 218.375ms
E/flutter ( 8594): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: SocketException: OS Error: Connection refused, errno = 111, address = bch0*kister*net, port = 44240
E/flutter ( 8594): #0 _NativeSocket.startConnect (dart:io-patch/socket_patch.dart:677:35)
E/flutter ( 8594): #1 _RawSocket.startConnect (dart:io-patch/socket_patch.dart:1680:26)
E/flutter ( 8594): #2 RawSocket.startConnect (dart:io-patch/socket_patch.dart:27:23)
E/flutter ( 8594): #3 RawSecureSocket.startConnect (dart:io/secure_socket.dart:237:22)
E/flutter ( 8594): #4 SecureSocket.startConnect (dart:io/secure_socket.dart:60:28)
E/flutter ( 8594): #5 _ConnectionTarget.connect (dart:_http/http_impl.dart:2437:24)
E/flutter ( 8594): #6 _HttpClient._getConnection.connect (dart:_http/http_impl.dart:2805:12)
E/flutter ( 8594): #7 _HttpClient._getConnection (dart:_http/http_impl.dart:2810:12)
E/flutter ( 8594): #8 _HttpClient._openUrl (dart:_http/http_impl.dart:2694:12)
E/flutter ( 8594): #9 _HttpClient.openUrl (dart:_http/http_impl.dart:2568:7)
E/flutter ( 8594): #10 _WebSocketImpl.connect (dart:_http/websocket_impl.dart:1027:24)
E/flutter ( 8594): #11 WebSocket.connect (dart:_http/websocket.dart:379:22)
E/flutter ( 8594): #12 JSONRPCWebsocket.connect
E/flutter ( 8594): #13 ElectrumFactory.getInstance
E/flutter ( 8594): #14 ElectrumFactory.getInstance
E/flutter ( 8594): <asynchronous suspension>
E/flutter ( 8594): #15 Wallet.refreshBalanceRemote
E/flutter ( 8594): <asynchronous suspension>
E/flutter ( 8594): #16 _DevToolsPageState.build.<anonymous closure>
E/flutter ( 8594): <asynchronous suspension>
E/flutter ( 8594):
E/flutter ( 8594): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: SocketException: OS Error: Connection refused, errno = 111, address = bch0*kister*net, port = 44238
E/flutter ( 8594): #0 _NativeSocket.startConnect (dart:io-patch/socket_patch.dart:677:35)
E/flutter ( 8594): #1 _RawSocket.startConnect (dart:io-patch/socket_patch.dart:1680:26)
E/flutter ( 8594): #2 RawSocket.startConnect (dart:io-patch/socket_patch.dart:27:23)
E/flutter ( 8594): #3 RawSecureSocket.startConnect (dart:io/secure_socket.dart:237:22)
E/flutter ( 8594): #4 SecureSocket.startConnect (dart:io/secure_socket.dart:60:28)
E/flutter ( 8594): #5 _ConnectionTarget.connect (dart:_http/http_impl.dart:2437:24)
E/flutter ( 8594): #6 _HttpClient._getConnection.connect (dart:_http/http_impl.dart:2805:12)
E/flutter ( 8594): #7 _HttpClient._getConnection (dart:_http/http_impl.dart:2810:12)
E/flutter ( 8594): #8 _HttpClient._openUrl (dart:_http/http_impl.dart:2694:12)
E/flutter ( 8594): #9 _HttpClient.openUrl (dart:_http/http_impl.dart:2568:7)
E/flutter ( 8594): #10 _WebSocketImpl.connect (dart:_http/websocket_impl.dart:1027:24)
E/flutter ( 8594): #11 WebSocket.connect (dart:_http/websocket.dart:379:22)
E/flutter ( 8594): #12 JSONRPCWebsocket.connect
E/flutter ( 8594): #13 ElectrumFactory.getInstance
E/flutter ( 8594): #14 Wallet.refreshBalanceRemote
E/flutter ( 8594): #15 _DevToolsPageState.build.<anonymous closure>
E/flutter ( 8594): #16 _DevToolsPageState.build.<anonymous closure>
E/flutter ( 8594): #17 _InkResponseState._handleTap
E/flutter ( 8594): #18 GestureRecognizer.invokeCallback
E/flutter ( 8594): #19 TapGestureRecognizer.handleTapUp
E/flutter ( 8594): #20 BaseTapGestureRecognizer._checkUp
E/flutter ( 8594): #21 BaseTapGestureRecognizer.handlePrimaryPointer
E/flutter ( 8594): #22 PrimaryPointerGestureRecognizer.handleEvent
E/flutter ( 8594): #23 PointerRouter._dispatch
E/flutter ( 8594): #24 PointerRouter._dispatchEventToRoutes.<anonymous closure>
E/flutter ( 8594): #25 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:400:8)
E/flutter ( 8594): #26 PointerRouter._dispatchEventToRoutes
E/flutter ( 8594): #27 PointerRouter.route
E/flutter ( 8594): #28 GestureBinding.handleEvent
E/flutter ( 8594): #29 GestureBinding.dispatchEvent
E/flutter ( 8594): #30 RendererBinding.dispatchEvent
E/flutter ( 8594): #31 GestureBinding._handlePointerEventImmediately
E/flutter ( 8594): #32 GestureBinding.handlePointerEvent
E/flutter ( 8594): #33 GestureBinding._flushPointerEventQueue
E/flutter ( 8594): #34 GestureBinding._handlePointerDataPacket
E/flutter ( 8594): #35 _rootRunUnary (dart:async/zone.dart:1444:13)
E/flutter ( 8594): #36 _CustomZone.runUnary (dart:async/zone.dart:1335:19)
E/flutter ( 8594): #37 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1244:7)
E/flutter ( 8594): #38 _invoke1 (dart:ui/hooks.dart:185:10)
E/flutter ( 8594): #39 PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:293:7)
E/flutter ( 8594): #40 _dispatchPointerDataPacket (dart:ui/hooks.dart:98:31)
E/flutter ( 8594):
E/flutter ( 8594): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: SocketException: OS Error: Connection refused, errno = 111, address = bch0*kister*net, port = 44250
E/flutter ( 8594): #0 _NativeSocket.startConnect (dart:io-patch/socket_patch.dart:677:35)
E/flutter ( 8594): #1 _RawSocket.startConnect (dart:io-patch/socket_patch.dart:1680:26)
E/flutter ( 8594): #2 RawSocket.startConnect (dart:io-patch/socket_patch.dart:27:23)
E/flutter ( 8594): #3 RawSecureSocket.startConnect (dart:io/secure_socket.dart:237:22)
E/flutter ( 8594): #4 SecureSocket.startConnect (dart:io/secure_socket.dart:60:28)
E/flutter ( 8594): #5 _ConnectionTarget.connect (dart:_http/http_impl.dart:2437:24)
E/flutter ( 8594): #6 _HttpClient._getConnection.connect (dart:_http/http_impl.dart:2805:12)
E/flutter ( 8594): #7 _HttpClient._getConnection (dart:_http/http_impl.dart:2810:12)
E/flutter ( 8594): #8 _HttpClient._openUrl (dart:_http/http_impl.dart:2694:12)
E/flutter ( 8594): #9 _HttpClient.openUrl (dart:_http/http_impl.dart:2568:7)
E/flutter ( 8594): #10 _WebSocketImpl.connect (dart:_http/websocket_impl.dart:1027:24)
E/flutter ( 8594): #11 WebSocket.connect (dart:_http/websocket.dart:379:22)
E/flutter ( 8594): #12 JSONRPCWebsocket.connect
E/flutter ( 8594): #13 ElectrumFactory.getInstance
E/flutter ( 8594): #14 ElectrumFactory.getInstance
E/flutter ( 8594): <asynchronous suspension>
E/flutter ( 8594): #15 Wallet.refreshBalanceRemote
E/flutter ( 8594): <asynchronous suspension>
E/flutter ( 8594): #16 _DevToolsPageState.build.<anonymous closure>
E/flutter ( 8594): <asynchronous suspension>
E/flutter ( 8594):
E/flutter ( 8594): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: SocketException: OS Error: Connection refused, errno = 111, address = bch0*kister*net, port = 44252
E/flutter ( 8594): #0 _NativeSocket.startConnect (dart:io-patch/socket_patch.dart:677:35)
E/flutter ( 8594): #1 _RawSocket.startConnect (dart:io-patch/socket_patch.dart:1680:26)
E/flutter ( 8594): #2 RawSocket.startConnect (dart:io-patch/socket_patch.dart:27:23)
E/flutter ( 8594): #3 RawSecureSocket.startConnect (dart:io/secure_socket.dart:237:22)
E/flutter ( 8594): #4 SecureSocket.startConnect (dart:io/secure_socket.dart:60:28)
E/flutter ( 8594): #5 _ConnectionTarget.connect (dart:_http/http_impl.dart:2437:24)
E/flutter ( 8594): #6 _HttpClient._getConnection.connect (dart:_http/http_impl.dart:2805:12)
E/flutter ( 8594): #7 _HttpClient._getConnection (dart:_http/http_impl.dart:2810:12)
E/flutter ( 8594): #8 _HttpClient._openUrl (dart:_http/http_impl.dart:2694:12)
E/flutter ( 8594): #9 _HttpClient.openUrl (dart:_http/http_impl.dart:2568:7)
E/flutter ( 8594): #10 _WebSocketImpl.connect (dart:_http/websocket_impl.dart:1027:24)
E/flutter ( 8594): #11 WebSocket.connect (dart:_http/websocket.dart:379:22)
E/flutter ( 8594): #12 JSONRPCWebsocket.connect
E/flutter ( 8594): #13 ElectrumFactory.getInstance
E/flutter ( 8594): #14 ElectrumFactory.getInstance
E/flutter ( 8594): <asynchronous suspension>
E/flutter ( 8594): #15 ElectrumFactory.getInstance
E/flutter ( 8594): <asynchronous suspension>
E/flutter ( 8594): #16 Wallet.refreshBalanceRemote
E/flutter ( 8594): <asynchronous suspension>
E/flutter ( 8594): #17 _DevToolsPageState.build.<anonymous closure>
E/flutter ( 8594): <asynchronous suspension>
E/flutter ( 8594):
And here is some of the RPCWebsocket code which is referenced in the error logs…:
void connect(String address) async {
_log.fine('starting to connect to $address');
_rpcSocket = await WebSocket.connect(address);
_log.fine('connected to websocket, current state ${rpcSocket.readyState}');
_rpcSocket.listen((dynamic data) {
// jsonDecode takes the raw JSON data and decodes into a map - jsonResult.
Map<String, dynamic> jsonResult = jsonDecode(data);
// Logs the resulting decoded Json.
// _log.fine('listening result: $jsonResult');
// Something is wrong with the logic here? We are attempting to
// deserialize into RPCResponse without first checking if
// it is a notification. However, in my logs, I rarely see
// a notification or case where there is no id...
// Attempt to deserialize response
final response = RPCResponse.fromJson(jsonResult);
// _log.fine('jsonResult id: ${response.id}');
// Checks if the result is a Notification (RPCRequest object)
// or a Response (RPCResponse object)
if (response.id == null) {
final notification = RPCRequest.fromJson(jsonResult);
return _handleNotification(notification);
}
return _handleResponse(response);
}, onError: (Object error) {
if (disconnectHandler != null) {
disconnectHandler(error);
}
for (final requestHandler in outstandingRequests.entries) {
requestHandler.value(RPCResponse(null,
error: Error(
0, 'Disconnected from electrum while awaiting response')));
}
}, onDone: () {
if (disconnectHandler != null) {
disconnectHandler(null);
}
for (final requestHandler in outstandingRequests.entries) {
requestHandler.value(RPCResponse(null,
error: Error(
0, 'Disconnected from electrum while awaiting response')));
}
// Nothing to do?
}, cancelOnError: true);
}
WebSocket get rpcSocket {
if (_rpcSocket == null) {
throw Exception('Socket disconnected prematurely');
}
return _rpcSocket;
}
class ElectrumClient extends JSONRPCWebsocket {
static final _log = Logger('ElectrumClient');
// ignore: unused_field
Timer _pingTimer;
ElectrumClient({DisconnectHandler disconnectHandler})
: super(disconnectHandler: disconnectHandler) {
_pingTimer = Timer(Duration(seconds: 60), () {
if (rpcSocket != null) {
print('ping');
serverPing();
}
});
}
class ElectrumFactory {
ElectrumFactory(this.urls, {this.onConnected});
ElectrumClient _client;
List<String> urls;
ConnectHandler onConnected;
/// Builds client if non-existent and attempts to connect before resolving.
Future<ElectrumClient> getInstance({int retry = 2}) async {
try {
if (_client == null) {
_client = ElectrumClient(disconnectHandler: (error) {
_client.dispose();
_client = null;
});
final urls = this.urls.sublist(0);
urls.shuffle();
// await _client.connect(Uri.parse(urls[0]));
_client.connect((urls[0]));
await onConnected(_client);
}
} catch (err) {
print(err);
_client = null;
if (retry == 0) {
rethrow;
}
return await getInstance(retry: retry - 1);
}
return _client;
}
}