appstream_embedd.js returns incorrect error object in EventListener for SESSION_ERROR - how to mitigate?

0

When starting a new AppStream, the appstream2.eu-west-1.aws.amazon.com/authenticate url is invoked by appstream_embed.js.

If called with an expired signed URL (typically happens if the user reloads the page), this endpoint returns a 400 - Bad Request. (401 would have been more suitable I would say.)

This triggers appstream_embed.js to show an error page to the end user as seen in Picture 1. This error tells the user that the user did a Bad Request, and suggest to the end user to "clear your cookies and try the request again". This will of course not work since the signed URL is expired. (Maybe this could be fixed by AWS AppStream team?)

We now try to cover up for this by listening to the event AppStream.Embed.Events.SESSION_ERROR, replacing the content in the end users browser with a more correct error message. However, in this event listener we get an incorrect error object! Also, for some reason it takes 5-10 seconds for this event listener to get invoked, and that is also very frustrating for us, when trying to get a correct error message out to the user.

The error object we get contains this, the wrong error code and incorrect error message:

{
  "errorCode": 500,
  "errorMessage": "The request processing has failed because of an unknown error, exception or failure."
}

Has anyone found a way around this

The code for our page is very simple, see code block below.

Picture 1: Enter image description here

Code Block 1:

<!DOCTYPE html>
<html>
  <head>
  </head>
  <body>
    <script type="text/javascript" src="assets/appstream_embed.js"></script>

    <script type="text/javascript">
      var appstreamEmbed;

      function launchAppStreamSession(sessionURL) {
        const streamingURL =
          "https://as-eu.apps.example.com/authenticate?parameters=" +
          sessionURL;
        var appstreamOptions = {
          sessionURL: streamingURL,
        };
        appstreamEmbed = new AppStream.Embed(
          "appstream-container",
          appstreamOptions
        );
        appstreamEmbed.addEventListener(
          AppStream.Embed.Events.SESSION_ERROR,
          (a) => {
            console.log("error=" + JSON.stringify(a));
            return false;
          }
        );
      }
    </script>

    <div
      id="appstream-container"
      style="visibility: visible; height: 100vh; margin: 0px"
    ></div>
    <script>
      sessionURL = window.location.hash.substring(1);
      launchAppStreamSession(sessionURL);
    </script>
  </body>
</html>
Andreax
질문됨 3달 전47회 조회
답변 없음

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인