thegrizzlylabs / sardine-android

A WebDAV library for Android
Apache License 2.0
355 stars 70 forks source link

sardine.put over https #18

Closed alexdiostia closed 5 years ago

alexdiostia commented 5 years ago

Hi i can authenticate successfully through Digest authentication and list the remote DAV folder.

However, i'm having an issue to put some files there, using the put(String, byte[]) method (url being of the form https://xxxxxxxxxxxxxxxx )

unfortunately it fails, with the following stacktrace. Any help more than welcome.

Server side is : Apache2 on Ubuntu 16.04, with timeout default (300s) Let's encrypt SSL certificate

W/System.err: javax.net.ssl.SSLException: Read error: ssl=0xae1327c0: I/O error during system call, Connection reset by peer W/System.err: at com.android.org.conscrypt.NativeCrypto.SSL_read(Native Method) at com.android.org.conscrypt.SslWrapper.read(SslWrapper.java:384) at com.android.org.conscrypt.ConscryptFileDescriptorSocket$SSLInputStream.read(ConscryptFileDescriptorSocket.java:541) at okio.Okio$2.read(Okio.java:140) at okio.AsyncTimeout$2.read(AsyncTimeout.java:237) W/System.err: at okio.RealBufferedSource.indexOf(RealBufferedSource.java:355) at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:227) at okhttp3.internal.http1.Http1Codec.readHeaderLine(Http1Codec.java:215) at okhttp3.internal.http1.Http1Codec.readResponseHeaders(Http1Codec.java:189) W/System.err: at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:88) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:45) W/System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121) at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) W/System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121) at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) W/System.err: at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:126) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121) W/System.err: at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:200) at okhttp3.RealCall.execute(RealCall.java:77) at com.thegrizzlylabs.sardineandroid.impl.OkHttpSardine.execute(OkHttpSardine.java:597) W/System.err: at com.thegrizzlylabs.sardineandroid.impl.OkHttpSardine.execute(OkHttpSardine.java:593) at com.thegrizzlylabs.sardineandroid.impl.OkHttpSardine.put(OkHttpSardine.java:329) at com.thegrizzlylabs.sardineandroid.impl.OkHttpSardine.put(OkHttpSardine.java:320) W/System.err: at com.thegrizzlylabs.sardineandroid.impl.OkHttpSardine.put(OkHttpSardine.java:299) at com.thegrizzlylabs.sardineandroid.impl.OkHttpSardine.put(OkHttpSardine.java:292) at com.PublishJob.processFiles(PublishJob.java:70) at com.MainActivity$7.run(MainActivity.java:275) W/System.err: at java.lang.Thread.run(Thread.java:764)

guillaume-tgl commented 5 years ago

Does it happen every time you try to upload or only occasionally? Have you tried with several file sizes? Which version of Android do you use and have you tried another version?

alexdiostia commented 5 years ago

Does it happen every time you try to upload or only occasionally? Have you tried with several file sizes? Which version of Android do you use and have you tried another version?

yes, i confirm it is a systematic problem, on both android 6 and 8 and with different file sizes

alexdiostia commented 5 years ago

Does it happen every time you try to upload or only occasionally? Have you tried with several file sizes? Which version of Android do you use and have you tried another version?

yes, i confirm it is a systematic problem, on both android 6 and 8 and with different file sizes

i probably faced some network issue, but overall, after reshaping my code:

However, i still can't use the put(), getting now a 403 Forbidden result : W/System.err: com.thegrizzlylabs.sardineandroid.impl.SardineException: Error contacting https://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.jpg (403 Forbidden) W/System.err: at com.thegrizzlylabs.sardineandroid.impl.handler.ValidatingResponseHandler.validateResponse(ValidatingResponseHandler.java:23) W/System.err: at com.thegrizzlylabs.sardineandroid.impl.handler.VoidResponseHandler.handleResponse(VoidResponseHandler.java:21) W/System.err: at com.thegrizzlylabs.sardineandroid.impl.handler.VoidResponseHandler.handleResponse(VoidResponseHandler.java:17) W/System.err: at com.thegrizzlylabs.sardineandroid.impl.OkHttpSardine.execute(OkHttpSardine.java:598) W/System.err: at com.thegrizzlylabs.sardineandroid.impl.OkHttpSardine.execute(OkHttpSardine.java:593) W/System.err: at com.thegrizzlylabs.sardineandroid.impl.OkHttpSardine.put(OkHttpSardine.java:329) W/System.err: at com.thegrizzlylabs.sardineandroid.impl.OkHttpSardine.put(OkHttpSardine.java:320) W/System.err: at com.thegrizzlylabs.sardineandroid.impl.OkHttpSardine.put(OkHttpSardine.java:299) W/System.err: at com.thegrizzlylabs.sardineandroid.impl.OkHttpSardine.put(OkHttpSardine.java:292)

ShineYang commented 5 years ago

Does it happen every time you try to upload or only occasionally? Have you tried with several file sizes? Which version of Android do you use and have you tried another version?

yes, i confirm it is a systematic problem, on both android 6 and 8 and with different file sizes

i probably faced some network issue, but overall, after reshaping my code:

  • list() and get() methods are working fine over the https calls
  • exists() throws a "400 Bad Request" exception if the resource exists (i would prefer the expected boolean "true" ;) ) but i can handle the exception manually

However, i still can't use the put(), getting now a 403 Forbidden result : W/System.err: com.thegrizzlylabs.sardineandroid.impl.SardineException: Error contacting https://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.jpg (403 Forbidden) W/System.err: at com.thegrizzlylabs.sardineandroid.impl.handler.ValidatingResponseHandler.validateResponse(ValidatingResponseHandler.java:23) W/System.err: at com.thegrizzlylabs.sardineandroid.impl.handler.VoidResponseHandler.handleResponse(VoidResponseHandler.java:21) W/System.err: at com.thegrizzlylabs.sardineandroid.impl.handler.VoidResponseHandler.handleResponse(VoidResponseHandler.java:17) W/System.err: at com.thegrizzlylabs.sardineandroid.impl.OkHttpSardine.execute(OkHttpSardine.java:598) W/System.err: at com.thegrizzlylabs.sardineandroid.impl.OkHttpSardine.execute(OkHttpSardine.java:593) W/System.err: at com.thegrizzlylabs.sardineandroid.impl.OkHttpSardine.put(OkHttpSardine.java:329) W/System.err: at com.thegrizzlylabs.sardineandroid.impl.OkHttpSardine.put(OkHttpSardine.java:320) W/System.err: at com.thegrizzlylabs.sardineandroid.impl.OkHttpSardine.put(OkHttpSardine.java:299) W/System.err: at com.thegrizzlylabs.sardineandroid.impl.OkHttpSardine.put(OkHttpSardine.java:292)

same problem. "However, i still can't use the put(), getting now a 403 Forbidden result : W/System.err: com.thegrizzlylabs.sardineandroid.impl.SardineException: Error contacting https://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.jpg (403 Forbidden)"

guillaume-tgl commented 5 years ago

Both the exist() and the put() methods have unit tests and the tests seem successful: https://github.com/thegrizzlylabs/sardine-android/blob/master/src/test/java/com/thegrizzlylabs/sardineandroid/FunctionalSardineTest.java#L498 https://github.com/thegrizzlylabs/sardine-android/blob/master/src/test/java/com/thegrizzlylabs/sardineandroid/FunctionalSardineTest.java#L394

These issues seem specific to your WebDAV server. What kind of server is it? How do you authenticate to your server? Have you tried to use another tool (such as Postman) to see if you get similar errors?

alexdiostia commented 5 years ago

ok, so it seems. i'm using Apache2 with webdav activated, running on ubuntu Mate i've probably something wrong in my config thanks for the tip, i'll check

guillaume-tgl commented 5 years ago

Closing for now, let me know if you an issue with sardine-android.

alexdiostia commented 5 years ago

i just found out that the put() issue comes from the folder structure. i succeeded the upload for the first time removing non existing folders from the file path. I had read before that the http put command should create the folders if not existing, but it's not the case here it seems. I let you decide if it's in the scope of sardine-android or not. Of course it would be better for me to have this check / folders creation managed automatically, but i'll now move forward doing it from my code