import 'dart:async';
import 'package:web_socket_channel/io.dart';
void main() {
final channel = IOWebSocketChannel.connect("ws://echo.websocket.org/",
pingInterval: Duration(milliseconds: 1000));
channel.stream.listen(print, onError: print, onDone: () => print('done'));
Timer.periodic(Duration(seconds: 3), (t) {
int time = DateTime.now().millisecondsSinceEpoch;
channel.sink.add("message: hi, $time");
});
Timer.periodic(Duration(seconds: 10), (t) {
print("close?");
print(channel.closeCode);
});
}
Websockets should be closed with
WebSocketStatus.GOING_AWAYif no pong message is received withinpingInterval. Why doesn't this work when connectivity is lost, e.g. with an un-plugged cable? Is this expected behaviour?Reproduce: