You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the connection is closed to the server, okhttp will try to reconnect and retry the request. This is expected because React Native Blob Util sets retryOnConnectionFailure to true on okhttp client. To re-create the request, okhttp client will call ReactNativeBlobUtilBody. writeTo(@nonnull BufferedSink sink) at which point ReactNativeBlobUtilBody will use the private variable requestStream to write into the BufferedSink. The problem is that the requestStream has already been used and closed when okhttp was making the first request. So this results in the requestStream not writing anything into the BufferedSink and okhttp will throw an error because the content length does not match the length of what was written into the BufferdSink (ie 0).
This started happening in our app when okhttp upgraded versions when we upgraded react-native. We would intermittently see "Unexpected End of Stream"
We have created an internal repro using an express mock server:
And then requesting it twice via React-Native-Blob-Util:
import RNFetchBlob from 'react-native-blob-util';
...
const headers = {
Connection: 'keep-alive',
};
await RNFetchBlob.config({
timeout: 3000,
}).fetch('POST', mockServerUrl + 'connectionWillBeDestroyed', headers, 'request body');
// wait to allow the mock server to close the connection. Anything less than 5 seconds did not suffice
await wait(5000);
// we expect this to fail internally within okhttp, at which point, okhttp will retry by recreating a request, which will fail
await RNFetchBlob.config({
timeout: 3000,
}).fetch('POST', mockServerUrl + 'connectionWillBeDestroyed', headers, 'request body');
I have a patch for my app that fixes this issue for us. I will submit a PR.
The text was updated successfully, but these errors were encountered:
The issue:
When the connection is closed to the server, okhttp will try to reconnect and retry the request. This is expected because React Native Blob Util sets retryOnConnectionFailure to true on okhttp client. To re-create the request, okhttp client will call ReactNativeBlobUtilBody. writeTo(@nonnull BufferedSink sink) at which point ReactNativeBlobUtilBody will use the private variable requestStream to write into the BufferedSink. The problem is that the requestStream has already been used and closed when okhttp was making the first request. So this results in the requestStream not writing anything into the BufferedSink and okhttp will throw an error because the content length does not match the length of what was written into the BufferdSink (ie 0).
This started happening in our app when okhttp upgraded versions when we upgraded react-native. We would intermittently see "Unexpected End of Stream"
We have created an internal repro using an express mock server:
And then requesting it twice via React-Native-Blob-Util:
I have a patch for my app that fixes this issue for us. I will submit a PR.
The text was updated successfully, but these errors were encountered: