Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8218623

HttpClient throws "RST_STREAM: Protocol error" when Http2 is not supported

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      os_x

      Description

      ADDITIONAL SYSTEM INFORMATION :
      openjdk version "13-ea" 2019-09-17
      OpenJDK Runtime Environment (build 13-ea+6)
      OpenJDK 64-Bit Server VM (build 13-ea+6, mixed mode, sharing)

      MacOS 10.14.2 Mojave

      A DESCRIPTION OF THE PROBLEM :
      The documentation for HttpClient states that it will automatically degrade to Http1 when v2 is not supported.

      However, when trying to use Spotify's api (which supports some access points in v2, but the majority in v1 [see https://github.com/spotify/web-api/issues/803]) the `Received RST_STREAM: Protocol error` exception is thrown.

      Configuring the HttpClient to use version 1.1 resolves the issue.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      HttpClient client = HttpClient.newHttpClient();
      String authCode = "..."
      HttpRequest req = HttpRequest.newBuilder()
                      .uri(URI.create("https://api.spotify.com/v1/tracks/54ucfuN596MU25jQD3KjCL"))
                      .header("Authentication", "Bearer " + authCode)
                      .GET().build();

      System.out.println(client.send(req, BodyHandlers.ofByteArray()).statusCode());

      ACTUAL -
      java.io.IOException: Received RST_STREAM: Protocol error
      at java.net.http/jdk.internal.net.http.HttpClientImpl.send(HttpClientImpl.java:576)
      at java.net.http/jdk.internal.net.http.HttpClientFacade.send(HttpClientFacade.java:119)
      at protocolerr/com.augustnagro.protocolerr.Main.sendReq(Main.java:38)
      at protocolerr/com.augustnagro.protocolerr.Main.main(Main.java:27)
      Caused by: java.io.IOException: Received RST_STREAM: Protocol error
      at java.net.http/jdk.internal.net.http.Stream.handleReset(Stream.java:487)
      at java.net.http/jdk.internal.net.http.Stream.schedule(Stream.java:177)
      at java.net.http/jdk.internal.net.http.common.SequentialScheduler$SynchronizedRestartableTask.run(SequentialScheduler.java:175)
      at java.net.http/jdk.internal.net.http.common.SequentialScheduler$CompleteRestartableTask.run(SequentialScheduler.java:147)
      at java.net.http/jdk.internal.net.http.common.SequentialScheduler$SchedulableTask.run(SequentialScheduler.java:198)
      at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:271)
      at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:224)
      at java.net.http/jdk.internal.net.http.Stream.receiveResetFrame(Stream.java:330)
      at java.net.http/jdk.internal.net.http.Stream.incoming_reset(Stream.java:465)
      at java.net.http/jdk.internal.net.http.Stream.otherFrame(Stream.java:401)
      at java.net.http/jdk.internal.net.http.Stream.incoming(Stream.java:391)
      at java.net.http/jdk.internal.net.http.Http2Connection.processFrame(Http2Connection.java:787)
      at java.net.http/jdk.internal.net.http.frame.FramesDecoder.decode(FramesDecoder.java:155)
      at java.net.http/jdk.internal.net.http.Http2Connection$FramesController.processReceivedData(Http2Connection.java:232)
      at java.net.http/jdk.internal.net.http.Http2Connection.asyncReceive(Http2Connection.java:649)
      at java.net.http/jdk.internal.net.http.Http2Connection$Http2TubeSubscriber.processQueue(Http2Connection.java:1275)
      at java.net.http/jdk.internal.net.http.common.SequentialScheduler$SynchronizedRestartableTask.run(SequentialScheduler.java:175)
      at java.net.http/jdk.internal.net.http.common.SequentialScheduler$CompleteRestartableTask.run(SequentialScheduler.java:147)
      at java.net.http/jdk.internal.net.http.common.SequentialScheduler$SchedulableTask.run(SequentialScheduler.java:198)
      at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:271)
      at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:224)
      at java.net.http/jdk.internal.net.http.Http2Connection$Http2TubeSubscriber.runOrSchedule(Http2Connection.java:1293)
      at java.net.http/jdk.internal.net.http.Http2Connection$Http2TubeSubscriber.onNext(Http2Connection.java:1319)
      at java.net.http/jdk.internal.net.http.Http2Connection$Http2TubeSubscriber.onNext(Http2Connection.java:1253)
      at java.net.http/jdk.internal.net.http.common.SSLTube$DelegateWrapper.onNext(SSLTube.java:202)
      at java.net.http/jdk.internal.net.http.common.SSLTube$SSLSubscriberWrapper.onNext(SSLTube.java:484)
      at java.net.http/jdk.internal.net.http.common.SSLTube$SSLSubscriberWrapper.onNext(SSLTube.java:287)
      at java.net.http/jdk.internal.net.http.common.SubscriberWrapper$DownstreamPusher.run1(SubscriberWrapper.java:318)
      at java.net.http/jdk.internal.net.http.common.SubscriberWrapper$DownstreamPusher.run(SubscriberWrapper.java:261)
      at java.net.http/jdk.internal.net.http.common.SequentialScheduler$SynchronizedRestartableTask.run(SequentialScheduler.java:175)
      at java.net.http/jdk.internal.net.http.common.SequentialScheduler$CompleteRestartableTask.run(SequentialScheduler.java:147)
      at java.net.http/jdk.internal.net.http.common.SequentialScheduler$SchedulableTask.run(SequentialScheduler.java:198)
      at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:271)
      at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:224)
      at java.net.http/jdk.internal.net.http.common.SubscriberWrapper.outgoing(SubscriberWrapper.java:234)
      at java.net.http/jdk.internal.net.http.common.SubscriberWrapper.outgoing(SubscriberWrapper.java:200)
      at java.net.http/jdk.internal.net.http.common.SSLFlowDelegate$Reader.processData(SSLFlowDelegate.java:403)
      at java.net.http/jdk.internal.net.http.common.SSLFlowDelegate$Reader$ReaderDownstreamPusher.run(SSLFlowDelegate.java:264)
      at java.net.http/jdk.internal.net.http.common.SequentialScheduler$SynchronizedRestartableTask.run(SequentialScheduler.java:175)
      at java.net.http/jdk.internal.net.http.common.SequentialScheduler$CompleteRestartableTask.run(SequentialScheduler.java:147)
      at java.net.http/jdk.internal.net.http.common.SequentialScheduler$SchedulableTask.run(SequentialScheduler.java:198)
      at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
      at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
      at java.base/java.lang.Thread.run(Thread.java:835)
      Exception in thread "main" java.util.concurrent.CompletionException: java.io.IOException: Received RST_STREAM: Protocol error
      at protocolerr/com.augustnagro.protocolerr.Main.sendReq(Main.java:42)
      at protocolerr/com.augustnagro.protocolerr.Main.main(Main.java:27)
      Caused by: java.io.IOException: Received RST_STREAM: Protocol error
      at java.net.http/jdk.internal.net.http.HttpClientImpl.send(HttpClientImpl.java:576)
      at java.net.http/jdk.internal.net.http.HttpClientFacade.send(HttpClientFacade.java:119)
      at protocolerr/com.augustnagro.protocolerr.Main.sendReq(Main.java:38)
      ... 1 more
      Caused by: java.io.IOException: Received RST_STREAM: Protocol error
      at java.net.http/jdk.internal.net.http.Stream.handleReset(Stream.java:487)
      at java.net.http/jdk.internal.net.http.Stream.schedule(Stream.java:177)
      at java.net.http/jdk.internal.net.http.common.SequentialScheduler$SynchronizedRestartableTask.run(SequentialScheduler.java:175)
      at java.net.http/jdk.internal.net.http.common.SequentialScheduler$CompleteRestartableTask.run(SequentialScheduler.java:147)
      at java.net.http/jdk.internal.net.http.common.SequentialScheduler$SchedulableTask.run(SequentialScheduler.java:198)
      at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:271)
      at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:224)
      at java.net.http/jdk.internal.net.http.Stream.receiveResetFrame(Stream.java:330)
      at java.net.http/jdk.internal.net.http.Stream.incoming_reset(Stream.java:465)
      at java.net.http/jdk.internal.net.http.Stream.otherFrame(Stream.java:401)
      at java.net.http/jdk.internal.net.http.Stream.incoming(Stream.java:391)
      at java.net.http/jdk.internal.net.http.Http2Connection.processFrame(Http2Connection.java:787)
      at java.net.http/jdk.internal.net.http.frame.FramesDecoder.decode(FramesDecoder.java:155)
      at java.net.http/jdk.internal.net.http.Http2Connection$FramesController.processReceivedData(Http2Connection.java:232)
      at java.net.http/jdk.internal.net.http.Http2Connection.asyncReceive(Http2Connection.java:649)
      at java.net.http/jdk.internal.net.http.Http2Connection$Http2TubeSubscriber.processQueue(Http2Connection.java:1275)
      at java.net.http/jdk.internal.net.http.common.SequentialScheduler$SynchronizedRestartableTask.run(SequentialScheduler.java:175)
      at java.net.http/jdk.internal.net.http.common.SequentialScheduler$CompleteRestartableTask.run(SequentialScheduler.java:147)
      at java.net.http/jdk.internal.net.http.common.SequentialScheduler$SchedulableTask.run(SequentialScheduler.java:198)
      at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:271)
      at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:224)
      at java.net.http/jdk.internal.net.http.Http2Connection$Http2TubeSubscriber.runOrSchedule(Http2Connection.java:1293)
      at java.net.http/jdk.internal.net.http.Http2Connection$Http2TubeSubscriber.onNext(Http2Connection.java:1319)
      at java.net.http/jdk.internal.net.http.Http2Connection$Http2TubeSubscriber.onNext(Http2Connection.java:1253)
      at java.net.http/jdk.internal.net.http.common.SSLTube$DelegateWrapper.onNext(SSLTube.java:202)
      at java.net.http/jdk.internal.net.http.common.SSLTube$SSLSubscriberWrapper.onNext(SSLTube.java:484)
      at java.net.http/jdk.internal.net.http.common.SSLTube$SSLSubscriberWrapper.onNext(SSLTube.java:287)
      at java.net.http/jdk.internal.net.http.common.SubscriberWrapper$DownstreamPusher.run1(SubscriberWrapper.java:318)
      at java.net.http/jdk.internal.net.http.common.SubscriberWrapper$DownstreamPusher.run(SubscriberWrapper.java:261)
      at java.net.http/jdk.internal.net.http.common.SequentialScheduler$SynchronizedRestartableTask.run(SequentialScheduler.java:175)
      at java.net.http/jdk.internal.net.http.common.SequentialScheduler$CompleteRestartableTask.run(SequentialScheduler.java:147)
      at java.net.http/jdk.internal.net.http.common.SequentialScheduler$SchedulableTask.run(SequentialScheduler.java:198)
      at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:271)
      at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:224)
      at java.net.http/jdk.internal.net.http.common.SubscriberWrapper.outgoing(SubscriberWrapper.java:234)
      at java.net.http/jdk.internal.net.http.common.SubscriberWrapper.outgoing(SubscriberWrapper.java:200)
      at java.net.http/jdk.internal.net.http.common.SSLFlowDelegate$Reader.processData(SSLFlowDelegate.java:403)
      at java.net.http/jdk.internal.net.http.common.SSLFlowDelegate$Reader$ReaderDownstreamPusher.run(SSLFlowDelegate.java:264)
      at java.net.http/jdk.internal.net.http.common.SequentialScheduler$SynchronizedRestartableTask.run(SequentialScheduler.java:175)
      at java.net.http/jdk.internal.net.http.common.SequentialScheduler$CompleteRestartableTask.run(SequentialScheduler.java:147)
      at java.net.http/jdk.internal.net.http.common.SequentialScheduler$SchedulableTask.run(SequentialScheduler.java:198)
      at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
      at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
      at java.base/java.lang.Thread.run(Thread.java:835)


      ---------- BEGIN SOURCE ----------
      HttpClient client = HttpClient.newHttpClient();
      String authCode = "..."
      HttpRequest req = HttpRequest.newBuilder()
                      .uri(URI.create("https://api.spotify.com/v1/tracks/54ucfuN596MU25jQD3KjCL"))
                      .header("Authentication", "Bearer " + authCode)
                      .GET().build();

      System.out.println(client.send(req, BodyHandlers.ofByteArray()).statusCode());
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Manually configure HttpClient to use Http1

      FREQUENCY : always


        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                chegar Chris Hegarty
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: