nginx HTTP/2 incompatible with okhttp (REFUSED_STREAM)



  • Hi,

    syncing with my current account and also creating a new account stopped.

    i mean it happens after updating php to 7.0.6 from 7.0.5 and nginx to 1.9.15 from 1.9.14 , before all works fine.
    also updating owncloud from 9.0.1 to 9.0.2 today does not helped.

    my server runs arch linux and i use the nginx config from here

    i use on DAVdroid 1.0.8 on CM13

    here are two logs, the first for syncing with the current account, the second one for creating new account

    EXCEPTION:
    java.io.IOException: stream was reset: REFUSED_STREAM
    	at okhttp3.internal.framed.FramedStream.checkOutNotClosed(FramedStream.java:574)
    	at okhttp3.internal.framed.FramedStream.access$1200(FramedStream.java:34)
    	at okhttp3.internal.framed.FramedStream$FramedDataSink.emitDataFrame(FramedStream.java:508)
    	at okhttp3.internal.framed.FramedStream$FramedDataSink.close(FramedStream.java:545)
    	at okio.RealBufferedSink.close(RealBufferedSink.java:241)
    	at okhttp3.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:705)
    	at at.bitfire.davdroid.HttpClient$PreemptiveAuthenticationInterceptor.intercept(HttpClient.java:153)
    	at okhttp3.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:681)
    	at at.bitfire.davdroid.HttpClient$UserAgentInterceptor.intercept(HttpClient.java:139)
    	at okhttp3.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:681)
    	at okhttp3.internal.http.HttpEngine.readResponse(HttpEngine.java:563)
    	at okhttp3.RealCall.getResponse(RealCall.java:241)
    	at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:198)
    	at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:160)
    	at okhttp3.RealCall.execute(RealCall.java:57)
    	at at.bitfire.dav4android.DavResource.propfind(DavResource.java:268)
    	at at.bitfire.davdroid.DavService$RefreshCollections.queryHomeSets(DavService.java:336)
    	at at.bitfire.davdroid.DavService$RefreshCollections.run(DavService.java:188)
    	at java.lang.Thread.run(Thread.java:818)
    
    
    2016-05-04 18:55:05 7 [ui.setup.DavResourceFinder] PROPFIND/OPTIONS on user-given URL failed
    EXCEPTION java.net.SocketTimeoutException: timeout
    	at okhttp3.internal.framed.FramedStream$StreamTimeout.newTimeoutException(FramedStream.java:600)
    	at okhttp3.internal.framed.FramedStream$StreamTimeout.exitAndThrowIfTimedOut(FramedStream.java:608)
    	at okhttp3.internal.framed.FramedStream$FramedDataSink.emitDataFrame(FramedStream.java:505)
    	at okhttp3.internal.framed.FramedStream$FramedDataSink.close(FramedStream.java:545)
    	at okio.RealBufferedSink.close(RealBufferedSink.java:241)
    	at okhttp3.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:705)
    	at at.bitfire.davdroid.HttpClient$PreemptiveAuthenticationInterceptor.intercept(HttpClient.java:153)
    	at okhttp3.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:681)
    	at at.bitfire.davdroid.HttpClient$UserAgentInterceptor.intercept(HttpClient.java:139)
    	at okhttp3.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:681)
    	at okhttp3.internal.http.HttpEngine.readResponse(HttpEngine.java:563)
    	at okhttp3.RealCall.getResponse(RealCall.java:241)
    	at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:198)
    	at okhttp3.logging.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.java:203)
    	at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:187)
    	at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:160)
    	at okhttp3.RealCall.execute(RealCall.java:57)
    	at at.bitfire.dav4android.DavResource.propfind(DavResource.java:268)
    	at at.bitfire.davdroid.ui.setup.DavResourceFinder.checkUserGivenURL(DavResourceFinder.java:156)
    	at at.bitfire.davdroid.ui.setup.DavResourceFinder.findInitialConfiguration(DavResourceFinder.java:116)
    	at at.bitfire.davdroid.ui.setup.DavResourceFinder.findInitialConfiguration(DavResourceFinder.java:87)
    	at at.bitfire.davdroid.ui.setup.DetectConfigurationFragment$ServerConfigurationLoader.loadInBackground(DetectConfigurationFragment.java:143)
    	at at.bitfire.davdroid.ui.setup.DetectConfigurationFragment$ServerConfigurationLoader.loadInBackground(DetectConfigurationFragment.java:126)
    	at android.support.v4.content.AsyncTaskLoader.onLoadInBackground(AsyncTaskLoader.java:296)
    	at android.support.v4.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:54)
    	at android.support.v4.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:42)
    	at android.support.v4.content.ModernAsyncTask$2.call(ModernAsyncTask.java:128)
    	at java.util.concurrent.FutureTask.run(FutureTask.java:237)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
    	at java.lang.Thread.run(Thread.java:818)
    

  • developer

    Hello,

    It's an HTTP/2 compatibility problem between okhttp (the library DAVdroid uses for HTTP access) and nginx. Please disable HTTP/2 on the server in the meanwhile.

    (This supports my personal opinion on HTTP/2, but I was not asked when Google forced it into the Internet.)

    Please tell us whether it works without HTTP/2.



  • hi,

    thanks for the fast reply and after changing my ngnix config from http2 to spdy all works fine again

    but i am a bit confused, because i swtched to http2 already for a month or so and it works fine until last week

    was something changed on davdroid?

    and will it works with http2 in some time again?



  • Downgrade nginx from 1.9.15 to 1.9.14 helps, then everything works fine again.



  • Concerning http://nginx.org/en/CHANGES it can be either

    *) Bugfix: when using HTTP/2 and the "limit_req" or "auth_request"
    directives a timeout or a "client violated flow control" error might
    occur while reading client request body; the bug had appeared in
    1.9.14.
    or
    *) Workaround: a response might not be shown by some browsers if HTTP/2
    was used and client request body was not fully read; the bug had
    appeared in 1.9.14.

    nginx-1.10.0 does not work either :(


  • admin

    @gilde said in (owncloud 9/nginx) syncing stopped:

    hi,

    thanks for the fast reply and after changing my ngnix config from http2 to spdy all works fine again

    but i am a bit confused, because i swtched to http2 already for a month or so and it works fine until last week

    was something changed on davdroid?

    and will it works with http2 in some time again?

    DAVdroid can handle HTTP/2 as soon as the developers of okhttp implement it into their lib. We use it in DAVdroid. We need to make a small release then too!



  • @devvv4ever Maybe you should consider rolling out a workaround patch in the meanwhile. Nginx with HTTP/2 support is included in the latest Ubuntu release, so one would imagine this problem potentially affects quite a lot of people running their own servers.

    Example of a workaround: https://github.com/wikimedia/apps-android-wikipedia/commit/058ed9cb5f4b77411f113cb31820e4a8687ee11a


  • developer

    There's a new "issue" for okhttp: Recover from REFUSED_STREAM in HTTP/2

    In the meanwhile, please just disable HTTP/2 on your server. This protocol doesn't seem to be stable enough yet.



  • Hello guys,

    Just a reply following my post, as it has been closed as duplicate of this thread and i cannot reply directly in my thread. I do not completely understand why this issue is linked to mine:
    I've tested a connection with another phone and the same version of DavDroid (and HTTP/2 activated), and it worked. So why it should come from the server? It seems a client problem to me.
    Second, I have already tried without HTTP/2 by setting my server like this, without success:

    server {
    #    listen 443 ssl http2;
        listen 443 ssl;
        server_name dav.mydomain.tld;
        root /srv/http/sabredav/;
    [...]
    

    Maybe i've misunderstood something, but could you please at least give some clue instead of closing the thread so quickly without much explanation?
    Thanks a lot


  • developer

    At the moment, we're unable to reproduce this problem with our own server (nginx 1.10.0, built with OpenSSL 1.0.1p-freebsd 9 Jul 2015) and DAVdroid 1.0.8 on various devices (Fairphone 2 with Android 5, Samsung Note 10.1, Samsung S2).

    Although HTTP/2 is enabled in nginx for the respective host (and used by browsers), DAVdroid (okhttp) won't use HTTP/2 …


  • developer

    According to https://github.com/square/okhttp/issues/2543#issuecomment-220778843:

    nginx attached a proposed patch on their issue tracker. I tested patch against OkHttp and it worked perfectly.

    So I still don't know whether this is a client library or server bug … my recommendation is to disable HTTP/2 everywhere where you can find it (e.g. nginx).



  • @rfc2822 It seems a client bug, because everything else works as expected.


  • developer

    @rfc2822 It seems a client bug, because everything else works as expected.

    Thanks for your hint, but "seems" is not enough here. We have to know where this error comes from, and then we can fix or work around it.



  • Just upgraded my server from Debian 8 to Ubuntu 16.04 with nginx 1.10. When HTTP2 is enabled davdroid doesn't work, when it's disabled it starts to work again. So I don't know where exactly is the problem but I would be glad to help if any kind of testing needs to be done.


  • developer

    According to https://github.com/square/okhttp/issues/2543#issuecomment-220831104, nginx has got a patch so that the default configuration will work with okhttp 3.2 (= DAVdroid 1.0.8) again. In my opinion, this would justify waiting and doing nothing until okhttp 3.3 is released, which will then be used in the next DAVdroid version.


  • developer

    nginx 1.11.0 has been released, and as far as I have understood it, in its default configuration there should be no more REFUSED_STREAM errors with okhttp. Can you please check?



  • @rfc2822 said in nginx HTTP/2 incompatible with okhttp (REFUSED_STREAM):

    nginx 1.11.0 has been released, and as far as I have understood it, in its default configuration there should be no more REFUSED_STREAM errors with okhttp. Can you please check?

    That's a shame that they didn't go with 1.10.1
    I don't think ubuntu will have it now. I have to compile from source. I will let you know.



  • @rfc2822 said in nginx HTTP/2 incompatible with okhttp (REFUSED_STREAM):

    nginx 1.11.0 has been released, and as far as I have understood it, in its default configuration there should be no more REFUSED_STREAM errors with okhttp. Can you please check?

    Tested via https://launchpad.net/~chris-lea/+archive/ubuntu/nginx-devel
    It works now!
    Thanks



  • FYI, okhttp 3.3.0 was released today, see https://github.com/square/okhttp/releases

    Hopefully we can re-enable HTTP/2 soon :)
    Raoul


  • developer

    DAVdroid with okhttp/3.3 has just been released.

    So I'm setting this to solved until this problem occurs again with DAVdroid 1.0.9.


Log in to reply
 

Looks like your connection to Bitfire App Forums was lost, please wait while we try to reconnect.