-
Notifications
You must be signed in to change notification settings - Fork 382
Frequent bad file descriptor errors on iOS #197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I deployed my iPhone Flutter app two days ago and saw this exact same issue yesterday (out of about 10 users). What is of note, is that this is a request which happened after the application was unpaused. (I suspend any attempts to get more data while the app is in the background and then resume when the app comes back). |
I am seeing this as well. How do you guys handle this when it occurs? |
Thanks @alanrussian for that link. This is a terrifying error for people who know Unix syscalls and not that special behavior :). It'd be great if Flutter on iOS could map this to a less scary error as my read of that link is that we should consider this like any other connection closed type event (except that this one happened due to the program's execution being suspended not the peer closing the connection). |
HttpException: Bad file descriptor, uri = https://domain/i_18409528_1647229044.jpg Empty stacktrace. |
Any update on this? |
up |
uuuuuup |
Same issue here:
|
@eric-khoury Exactly the same for us. Seems to be on a failed NetworkImage.load in our case:
|
This should be fixed because it happens to frequently on IOS devices. |
I have this error a lot as well since all the Iphones did the last update, what can be done about it ? |
Same here. Frequently happens on IOS devices |
Facing this issue as well |
Same here iOS 16.1
|
I am seeing the same issue on an iPhone X, running iOS 15.0. Any ideas on how to fix this? |
Our new logger revealed a bit more detail on this, here is stacktrace:
|
Same issue here, were you able to solve this issue? |
Same issue here! |
same issue here. |
same issue here |
1 similar comment
same issue here |
Happening with me too when application goes in background and brought back in foreground after sometime, not sure if this is http or network? |
why is this ticket still open and not assigned to anyone? |
@dr0-dev Because it's normal for iOS to do this and there's nothing to suggest anything is wrong on the Flutter side, other than to think about overriding the OS error message to something more specific so people stop worrying about it? |
Is there any update on this open issue please? |
Hi, As @alanrussian said, it is not unexpected for sockets to be invalidated when the app is suspended. From Apple's Documentation:
Wrapping your Reducing You could also consider using
I'm open to ideas on what else we can do e.g.
Something else? @natebosch Any ideas? |
Someone on the Flutter team had a suggestion: we add a method to clear the connection pool on HttpClient and we ask developers to do that before their apps are suspended. So something like this: HttpClient client;
...
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
super.didChangeAppLifecycleState(state);
if (state == AppLifecycleState.paused) {
client.clearConnectionPool(); // Think of a better name.
}
} |
@hls-app Are you sure that you are using Because only the |
@brianquinlan yes, using cupertino_http _ClientSocketException: ClientException with SocketException: Bad file descriptor (OS Error: Bad file descriptor, errno =... HttpApiClient({Client? httpClient})
: _httpClient = httpClient ??
(Platform.isIOS
? CupertinoClient.defaultSessionConfiguration()
: CronetClient.defaultCronetEngine()); The The URI link was a 404. |
I agree that this is an issue but it isn't one that can be easily fixed with In the documentation for Could you be more explicit on what actions I should take to make this better? Thanks! P.S. I spend a lot of time trying to make the Dart HTTP ecosystem better and I find your comment unkind. I also don't know what it means to "acknowledge" an issue but this is my 13th comment on this issue so I'm definitely aware that it exists ;-) |
Do you work on the Flutter team? I don't think it is unkind at all to express disappointment. Additionally, this issue has never been triaged, assigned, or otherwise updated past your comment to try another library. As much as you may not like the wording in my post, those are facts - there is no way for a person coming to this thread to resolve this issue.
Do you have a reply to this? Because this is where it ended for me too. It also reinforces what I'm saying. One can post all they want - will one get a follow up? This is why I made the comments I did in the second paragraph. There's still no resolution for me. No leads. And the one follow up I got said they didn't like what I said. I don't know what I could do better either. Either way, thank you for your work on the platform. |
I don't think that it is possible for you to be using |
I work on the Dart team and I think that using
I just replied: #197 (comment)
Did you try using
Were you able to reproduce the issue using |
I have cases where I'm using http only, and yes there does seem to be some relief if that is one's only dependency. My other case is slightly more complicated - but I get tens of thousands of these errors when using it - I am using Websocket, similar to these posts: I agree with them that this is useful, but only partly implemented. Is there something we can doing to improve the situation? The easiest way I've found to cause these errors is by connecting like below, with the IP address unavailable (causes either WebsocketException or SocketException, depending on the connection type):
|
I think that the problem is that you are still using socket-based transport. Have you tried using CupertinoWebSocket with |
I believe you're right. I'm going to need to take some time to evaluate, as this is a very burly part of our codebase (it is an IoT based product). I didn't think we had this option when I looked around a few months ago. Thank you for adding it. |
UPDATE: native_dio_adapter fixed it! Not only do I no longer have strange iOS behavior after restarting app, but I refactored the dio instance to be a singleton (without closing it so often) and boom, everything running very fast. |
FWIW, ( |
Hi, I have read the previous messages. I am using mqtt5client: ^4.5.3 and I am facing the same problem on iOS.
Do you know if there is a solution? Any information is appreciated. |
I am using web_socket_channel 3.0.1 and got WebSocketChannelException: SocketException: Bad file descriptor (OS Error: Bad file descriptor, errno = 9), address =, port = 61293 on ios flutter version 3.24.3 |
6 years and still time is ticking... |
Did you try using |
There is definitely a significant reduction in exceptions when using native_dio_adapter, but it does not resolve all occurrences of HttpException / SocketException (bad file descriptor). As an example:
happens when there was a previous exception:
We did however, see a reduction of these type of events from thousands a month to just a handful. Definitely an improvement. |
we can confirm using Maybe a note could be added to the documentation that using this package on ios is highly recommended, otherwise problems like the one described in this issue can occur. (also explicitly link to this issue) |
I'm also getting
With the following stacktrace (I'm using version
The majority are from iPhone users but I also get this from a smaller proportion of Android users. This may technically be a slightly different issue because it's a ClientException not OS Error as raised by the OP, but I thought it was relevant to post here because the problem I had was the vague / misleading error message which is one of the points raised in the original issue. I received this error in a part of my code which calls Google Drive APIs to upload files, and I spent several days going on a wild goose chase because I assumed |
Hey @aipok Thanks for the data! What firebase package are you using? The packages that I found use |
@brianquinlan another stopper in this case, which I didn't found how to solve, other as to rewrite everything, is the
The IOHttpClientAdapter is expecting HttpClient and not the |
@brianquinlan as for Firebase packages. The most used and where we got a lot of errors are the |
@brianquinlan My personal opinion about the issue or at least it feels like this, that the real problem is hidden somewhere in between Flutter and Native layers. It really feels that my app process was blocked from the network access completely, while I got this error on my device. Because I was able to use any other apps at the same time and they had no problem with the connection, but my app did have the issue and changing the network during the error also have no effect. App process just have no access to the system network. While the error exists nothing able to get to the network, not the http calls, nor the websockets etc. |
From looking at the code, it seems like the Firebase products are using native plugins for transport so this issue is not related to dart. As @kuhnroyal pointed out, |
@kuhnroyal @brianquinlan |
This is also happening with @brianquinlan Do you have any idea how to handle this issue in a more general way? |
We deploy a Flutter app and have been noticing frequent exceptions from our HTTP requests:
From my discussion with @johnfesa, it is sometimes expected for iOS to throw these bad file descriptor errors. See Apple's Networking and Multitasking documentation. However, we're filing this issue for a few reasons:
Since this exception is expected to occur on iOS, we were wondering if it might be a good idea to raise a more specific exception than a generic OS error.
We're noticing this error frequently enough that we wanted to double check that there isn't an issue with the way the sockets are being managed that would be causing it.
The text was updated successfully, but these errors were encountered: