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
asked 2 months ago45 views
No Answers

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions