Flutter: Connection closed while receiving data Flutter: Connection closed while receiving data dart dart

Flutter: Connection closed while receiving data


Keep-Alive header in the headers of your request might be missing, please check with APIs required headers


I had the issue with a get request, sometimes I get the response from the server and sometimes I receive the exception Connection closed while receiving data on same button click event. Then I founded that the number of records of particular table in database is quite large. My suggested solution is to use pagination in the backend server.


It depends on the server or Rest API you are trying to call.

Sometimes it is a matter of double checking you are using a valid and appropriate URL endpoint.

Another possibility is that it is not correctly receiving authentication at the header. I had that problem once and it got solved authenticating trough the url as endpoints. Try researching if the server or rest api supports other authentication options as this last one mentioned.