Write to a dead socket fails only after ~4 minute on iOS
- Dominant language
- Dart
- Stars
- 1.1k
- Forks
- 419
- Avg merge
- 4d 14h
- Merged PRs (30d)
- 8
Description
Scenario is simple:
1) prepare iOS - I use wifi connection to internet and mobile connection is off
2) use code - it almost from flutter docs + some logs [https://github.com/nailgilaziev/ws_change_network_reaction/blob/issue_dead_socket_time/lib/main.dart ](url)
3) run and it must connect to echo server
4) write "online" and press send - see reaction in logs - all good
5) **switch off wifi on iOS**
6) write "offline" and press send - and... wait reaction in logs...
...wait around 4 minute for detecting that connection is failed. It's too long!!!
Writing to a dead socket connection **should not fail over 4 min**!
Logs that you see when run this scenario:
```
flutter: time 2019-06-27 21:21:02.985554
flutter: connection state ConnectionState.waiting
flutter: data null
flutter: error null
flutter:
flutter: time 2019-06-27 21:21:11.949830
flutter: send pressed with payload: online
flutter:
flutter: time 2019-06-27 21:21:12.368631
flutter: connection state ConnectionState.active
flutter: data online
flutter: error null
flutter:
//-------------HERE WIFI IS SWITCHED OFF -------------
flutter: time 2019-06-27 21:21:21.075945
flutter: send pressed with payload: offline
flutter:
flutter: time 2019-06-27 21:25:22.155111
flutter: connection state ConnectionState.done
flutter: data online
flutter: error null
```
at ~21:21:21 wifi is switched off
at =21:25:22 done event emitted
ps.
Switching off wifi is not an only one case. You can use apple Network link conditioner tool with 100% loss profile to emulate similar (but not the same) situation. For user perspective is the same: Done event occur after ~ 4 min. But it's not the same because in TCP layer things looks different. By switching off wifi OS sends [FIN,ACK] packet to server. By setting 100% profile nothing send to server.
On android behaviour different:
* switching off wifi cause emitting momentally ConnectionState.done before we can write msg
* with 100% profile behaviour like in iOS, but it fails faster. almost a **2 min**
___
web_socket_channel: ^1.0.13
Flutter 1.5.4-hotfix.2 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 7a4c33425d (8 weeks ago) • 2019-04-29 11:05:24 -0700
Engine • revision 52c7a1e849
Tools • Dart 2.3.0 (build 2.3.0-dev.0.5 a1668566e5)
MacOS mojave 10.14.5 (18F203
Contributor guide
Assessment
This issue has not been assessed yet.