braverhealth / phoenix-socket-dart

Cross-platform and stream-based implementation of Phoenix Sockets
https://pub.dev/packages/phoenix_socket
BSD 3-Clause "New" or "Revised" License
74 stars 37 forks source link

Exception when connection is terminated by system #8

Closed hamann closed 3 years ago

hamann commented 3 years ago

When an app is in background and the system terminates the connection (on iOS/simulator after about ~30 secs), launching the app again raises an exception

flutter: 2020-11-01 23:43:52.584295 FINE phoenix_socket.socket - [phoenix_socket] Heartbeat completed
...somewhere inbetween the connection terminates
flutter: 2020-11-01 23:46:38.254694 INFO phoenix_socket.socket - Socket closed with reason  and code 1000
flutter: 2020-11-01 23:46:38.258508 FINE phoenix_socket.socket - Trigger channel exceptions on 1 channels
flutter: 2020-11-01 23:46:38.259269 FINE phoenix_socket.channel.user - Receiving error on channel
### PhoenixException: PhoenixException: socket closed
flutter: 2020-11-01 23:46:38.260450 WARNING phoenix_socket.channel.user - Got error on channel
### PhoenixException: PhoenixException: socket closed

Call stack:

PhoenixSocket._sendHeartbeat (/usr/local/Caskroom/flutter/1.20.4/flutter/.pub-cache/hosted/pub.dartlang.org/phoenix_socket-0.4.4/lib/src/socket.dart:408)
<asynchronous gap> (Unknown Source:0)
PhoenixSocket._sendHeartbeat (/usr/local/Caskroom/flutter/1.20.4/flutter/.pub-cache/hosted/pub.dartlang.org/phoenix_socket-0.4.4/lib/src/socket.dart:0)
_rootRunUnary (dart:async/zone.dart:1198)
_rootRunUnary (dart:async/zone.dart:0)
_CustomZone.runUnary (dart:async/zone.dart:1100)
_CustomZone.runUnaryGuarded (dart:async/zone.dart:1005)
_CustomZone.bindUnaryCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1042)
_rootRunUnary (dart:async/zone.dart:1206)
_rootRunUnary (dart:async/zone.dart:0)
_CustomZone.runUnary (dart:async/zone.dart:1100)
_CustomZone.bindUnaryCallback.<anonymous closure> (dart:async/zone.dart:1026)
_Closure.call (dart:core-patch/function.dart:0)
_Timer._runTimers (dart:isolate-patch/timer_impl.dart:397)
_Timer._handleMessage (dart:isolate-patch/timer_impl.dart:428)
_Timer._handleMessage (dart:isolate-patch/timer_impl.dart:0)
_Closure.call (dart:core-patch/function.dart:0)
_RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168)
Bildschirmfoto 2020-11-01 um 23 50 34
matehat commented 3 years ago

@hamann I just pushed a commit that might fix that, can you retry with master?

hamann commented 3 years ago

@matehat 👍