We have an issue when using dart client to access our api.
After our app is running a while, with calls against the api in the background, we get errors like “too many files open” which means the File Descriptors are running out.
During investigations on the ipad simulator i found out that a lot of connections are in state “established” but are not being closed by the service client.
Result of lsof (The list is much longer but it’s always the same entry)
In the code we have an instance of the jsonserviceclient, which we then use with “normal” get requests
var result = await client.get(request)
I tried to set the Connection Header to close but it didn’t help.
It looks like either the Servicestack client or the HttpClient of Dart is not closing the connection.
Don’t know then, the only place you can close a HttpClientRequest is before you get a response so I’m not seeing where the leak is if you’re using reusing the same JsonServiceClient instance.
Can you provide a small repro example that causes a connection leak?
I tried now to close the http client after each run of multiple requests and now it doesn’t happen anymore but i have now to create a new instance before making some requests.
To close i use
serviceClient.client.close(force: true)