Repository: flutter
Issue: Switching off network provider on iOS does not immediately stop WebSocket connection
Labels: platform-ios,engine,dependency: dart,has reproducible steps,P3,dependency: dart:io,found in release: 3.3,found in release: 3.7,team-ios,triaged-ios

Switching off WiFi or mobile network provider on iOS while websocket connection is alive should cause immediately emitting done(close) event to listening streams. But this does not happen on iOS in contrast to Android.

*Preparations to reproduce the issue:*
1) grab the test code: [github project main.dart](https://github.com/nailgilaziev/ws_change_network_reaction/blob/issue_dartio/lib/main.dart)
2) prepare iOS: I use wifi connection to the internet and mobile connection is off for now. But it doesn't depend on that case. you can use all of combinations: Mobile-on/wifi-off, all providers enabled, etc. Behaviour the same for different network providers and not matter what you use. 

*Running scenario:*
1) run and it must connect to echo server - logs show it
2) write "something" and press send - see reaction in logs - all good
3) switch off WiFi on iOS
4) wait reaction in logs...

**Logs**
*on iOS after switching WiFi provider nothing happens*
```
17:24:46.693459   connect to ws://echo.websocket.org requested
17:24:49.312085   connect successfully established
17:25:07.964240   Sended р
17:25:08.282754   ws.listen received = р
// --- WIFI SWITCHED OFF---
// you can wait forever, nothing will happen
```
If you do the same on android, close event emitted to both done listeners:

*on Android after switching off WiFi provider everything works as it should*
```
17:29:08.166856   connect to ws://echo.websocket.org requested
17:29:12.425252   connect successfully established
17:29:39.879199   sended y
17:29:40.267743   ws.listen received = y
// --- WIFI SWITCHED OFF---
17:29:44.711755   ws.listen.onDone called
17:29:44.770376   ws.done.then with details:
closecode 1002 closeReason null readyState 1
```

PS. Why readyState is 1? (open) Is another story and another issue... [dart/sdk issue](https://github.com/dart-lang/sdk/issues/33362)

This behaviour is reproduced in stable channel 
```
Flutter 1.5.4-hotfix.2 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 7a4c33425d (9 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)

[✓] Flutter (Channel stable, v1.5.4-hotfix.2, on Mac OS X 10.14.5 18F203, locale en-RU)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] iOS toolchain - develop for iOS devices (Xcode 10.2.1)
[✓] Android Studio (version 3.4)
[✓] IntelliJ IDEA Ultimate Edition (version 2019.1.3)
[✓] Connected device (3 available)
```
And reproduced in master channel too
```
Flutter 1.7.11-pre.45 • channel master • https://github.com/flutter/flutter.git
Framework • revision bbbd240635 (83 minutes ago) • 2019-06-28 04:41:55 -0400
Engine • revision 4aaa1a9488
Tools • Dart 2.4.0

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel master, v1.7.11-pre.45, on Mac OS X 10.14.5 18F203, locale en-RU)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 10.2.1)
[✓] iOS tools - develop for iOS devices
[✓] Chrome - develop for the web
[✓] Android Studio (version 3.4)
[✓] IntelliJ IDEA Ultimate Edition (version 2019.1.3)
[✓] Connected device (5 available)
```