Open gutisalex opened 3 years ago
+1
+1
In our test, there's no different between import 'package:http/http.dart' as httpClient;
or RouterApiClient({http.Client httpClient}) : _httpClient = httpClient ?? http.Client();
, when we post to mush post http request at the same time, the errors still going on, no matter with instantiate or not.
Hey I am facing a really weird problem I am not able to solve...
I wrote a client for a wifi router I am working with right now. I am using the bloc architecture for this. So I have my bloc which asks a repository for certain data which is calling methods from the routerApiClient.
In the routerApiClient I import http like this:
and use
that works!
But if I import http like this:
and instantiate the http client like this:
and use
the first call works fine but with the second call (which is called right after the first one) I get the following error:
Connection closed before full header was received
Here are the calls:
I have another provider which fetches data from an API from a remote server using the exact same approach and for some reason there it works... The only difference is the wifi router uses http and the webserver uses https.
It looks like the calls are being triggered too fast one after another, because after this has failed I can do other calls as normal.
I only don't know why it works if I use the import alias directly and why it doesn't when instantiating the httpClient in the constructor?!
Any ideas?
Edit: I can confirm they are being trigged too fast one after another. I just put a timeout in between and it works. Can I solve this in another way?