react-native-fetch-blob
react-native-fetch-blob copied to clipboard
Android: Unexpected end of stream - bugs after updating SDK
Problem
I am making presigned putObject
requests like this (to AWS S3):
RNFetchBlob.fetch(
'PUT',
someUrl,
{ 'Content-Type': 'application/octet-stream' },
RNFetchBlob.wrap(pathToImageFile)
)
And it worked perfectly until I updated my Android SDK (to these versions):
- Android SDK Tools 25.2.2
- Android SDK Platform-tools 24.0.3
- SDK Platform (API 23) 23.0.3
I don't know what the versions were before and I don't think I can downgrade them either. Any clue where to start?
Edit: PUT
ing with httpie
still works as it did before.
http put someUrl Content-Type:application/octet-stream < pathToImageFile
Versions
- "react-native-fetch-blob": "^0.9.6"
- "react-native": "^0.35.0-rc.0"
console.warn
in chrome dev tools console
This is what the dev tools give me before crashing the app with the unexpected end of stream
error.
timeout
RNFetchBlob error when sending request : unexpected end of stream
timeout
Stacktrace from adb logcat
10-10 20:16:24.081 6042 6982 W System.err: java.net.SocketTimeoutException: timeout
10-10 20:16:24.083 6042 6982 W System.err: at okio.Okio$3.newTimeoutException(Okio.java:210)
10-10 20:16:24.084 6042 6982 W System.err: at okio.AsyncTimeout.exit(AsyncTimeout.java:277)
10-10 20:16:24.084 6042 6982 W System.err: at okio.AsyncTimeout$1.write(AsyncTimeout.java:186)
10-10 20:16:24.084 6042 6982 W System.err: at okio.RealBufferedSink.emitCompleteSegments(RealBufferedSink.java:171)
10-10 20:16:24.084 6042 6982 W System.err: at okio.RealBufferedSink.write(RealBufferedSink.java:41)
10-10 20:16:24.084 6042 6982 W System.err: at okhttp3.internal.http.Http1xStream$FixedLengthSink.write(Http1xStream.java:282)
10-10 20:16:24.084 6042 6982 W System.err: at okio.RealBufferedSink.emitCompleteSegments(RealBufferedSink.java:171)
10-10 20:16:24.084 6042 6982 W System.err: at okio.RealBufferedSink.write(RealBufferedSink.java:91)
10-10 20:16:24.084 6042 6982 W System.err: at com.RNFetchBlob.RNFetchBlobBody.pipeStreamToSink(RNFetchBlobBody.java:268)
10-10 20:16:24.084 6042 6982 W System.err: at com.RNFetchBlob.RNFetchBlobBody.writeTo(RNFetchBlobBody.java:119)
10-10 20:16:24.084 6042 6982 W System.err: at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:47)
10-10 20:16:24.084 6042 6982 W System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
10-10 20:16:24.084 6042 6982 W System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
10-10 20:16:24.084 6042 6982 W System.err: at com.RNFetchBlob.RNFetchBlobReq$1.intercept(RNFetchBlobReq.java:298)
10-10 20:16:24.084 6042 6982 W System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
10-10 20:16:24.084 6042 6982 W System.err: at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:45)
10-10 20:16:24.084 6042 6982 W System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
10-10 20:16:24.085 6042 6982 W System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
10-10 20:16:24.085 6042 6982 W System.err: at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:109)
10-10 20:16:24.085 6042 6982 W System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
10-10 20:16:24.085 6042 6982 W System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
10-10 20:16:24.085 6042 6982 W System.err: at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
10-10 20:16:24.085 6042 6982 W System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
10-10 20:16:24.085 6042 6982 W System.err: at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:124)
10-10 20:16:24.085 6042 6982 W System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
10-10 20:16:24.085 6042 6982 W System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
10-10 20:16:24.085 6042 6982 W System.err: at com.RNFetchBlob.RNFetchBlobReq$2.intercept(RNFetchBlobReq.java:306)
10-10 20:16:24.085 6042 6982 W System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
10-10 20:16:24.085 6042 6982 W System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
10-10 20:16:24.085 6042 6982 W System.err: at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:170)
10-10 20:16:24.085 6042 6982 W System.err: at okhttp3.RealCall.access$100(RealCall.java:33)
10-10 20:16:24.085 6042 6982 W System.err: at okhttp3.RealCall$AsyncCall.execute(RealCall.java:120)
10-10 20:16:24.085 6042 6982 W System.err: at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
10-10 20:16:24.086 6042 6982 W System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
10-10 20:16:24.086 6042 6982 W System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
10-10 20:16:24.086 6042 6982 W System.err: at java.lang.Thread.run(Thread.java:818)
Edit 2016-10-11
The same code is working on iOS (10.0.2).
Not sure how to reproduce it, but looks like it happens when using fixed length request. I will look into it.
Android: RNFetchBlobBody.java : 199: header += "Content-Disposition: form-data; name=" + name + "; filename=" + field.filename + "\r\n";
IOS: RNFetchBlobReqBuilder.m: 203: [formData appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name="%@"; filename="%@"\r\n", name, filename] dataUsingEncoding:NSUTF8StringEncoding]];
IOS have '"' But Android not have。
@wkh237 Did you find anything ?
@havishhuda
it worked for me
RNFetchBlobBody.java : 199:
header += "Content-Disposition: form-data; name=\"" + name + "\"; filename=\"" + field.filename + "\"\r\n";
Hi @hujiudeyang facing the same problem here.
Everything works fine on android 5.0 and 5.1, IOs works fine too.
But on 6.0+ I have the same problem.
[Error: unexpected end of stream]
Did you solve this?
@wkh237 did you test this, or have some kinda of fix?
The error occurs in react-native-fetch-blob/index.js
I am using Android Oreo 8.0 on Galaxy S9 and Oreo 8.1 on PixelXL2 RN 0.55.0 React 16.3.2 react native fetch blob 0.10.8