Android - React Native file upload - unexpected end of stream, broken pipe

199 views Asked by At

I have a react-native app. The app uploads files using rn-fetch-blob. This has worked previously with no issue. I am attempting to upgrade RN (to version 0.66.5) as the project was a little behind this. iOS is working fine but on Android whenever I attempt to upload a file I get the error:

unexpected end of stream / broken pipe

The problem seems to stem from okhttp3 which is used within the rn-fetch-blob package.

I have read a few possible solutions for this and have tried the following with no luck:

  • update the Flipper version
  • I have patched the package as per here - this is a continuation of the rn-fetch-blob package
  • force the version of okttp to a later version (4.9.1)

Can anyone help?

1

There are 1 answers

0
demon On

First of all, I solve by adding this in the upload request headers.

Connection: 'close',

I guess it happens with the HTTP connection.At the beginning, i use fetch ,but it throw Network request failed.And after i use rn-fetch-blob ,it throw unexpected end of stream.