sebkoller / certificate_pinning_httpclient

MIT License
6 stars 8 forks source link

Connection Closed when there are multiple requests coming at the same time #9

Open PutawanDE opened 2 months ago

PutawanDE commented 2 months ago

Error

Get SocketException when firing two or more requests at the same time on first opening of the app Connection closed before full header was received sometime it is Connection attempt cancelled.

PutawanDE commented 2 months ago

I looked into this bug. It is a race condition while it is fetching certificates to create a HTTP client. The first request will create a HTTP client. During the period of retrieving the certificate, the second requests come in. The second request should use the created HTTP client, but it is not yet finished creating. This will create the second client. And once the second once is created, the first one will be closed while it is not finished with the request.