A lot of connection errors when send requests in Timer.periodic
I need to send a POST request every minute. So I use Timer.periodic for it.
In debug mode there is no problem. But in production there are hundreds of:
SocketException: Failed host lookup
Connecting timed out [0ms]
SocketException: Software caused connection abort
SocketException: Bad file descriptor
HandshakeException: Connection terminated during handshake
I see them in Sentry. I am absolutely sure there was no problems with internet connection. Besides, half of requests reach the destination.
void _startSendingDeviceActivity() {
_sendDeviceActiviryTimer?.cancel();
_sendDeviceActivity();
_sendDeviceActiviryTimer = Timer.periodic(const Duration(minutes: 1), _sendDeviceActivity);
}
Future<void> _sendDeviceActivity([_]) async {
final DeviceInfo deviceInfo = await DeviceActivity.getDeviceInfo();
_userApi.sendDeviceActivity(deviceInfo);
}
@override
void dispose() {
_sendDeviceActiviryTimer?.cancel();
super.dispose();
}
New Issue Checklist
- [x] I have searched for a similar issue in the project and found none
Issue Info
| Info | Value | |
|---|---|---|
| Platform Name | flutter | |
| Platform Version | 2.10.5 | |
| Dio Version | 4.0.6 | |
| Android Studio / Xcode Version | Android Studio 2021.1.1 patch 2 / Xcode 13.2.1 | |
| Repro rate | sometimes ~50% | |
| Repro with our demo prj | idk | |
| Demo project link | - |
Issue Description and Steps
Please fill in the detailed description of the issue (full output of any stack trace, compiler error, ...) and the steps to reproduce the issue.
Any answer?
Hi @justjew , we have the same problem. Do you have any update regarding this?
Same question here