Encountered a "HttpNotFoundException" error when attempting to establish a Websocket connection to AppSync

Encountering an issue while attempting to establish a Websocket connection to AWS AppSync. Upon connecting, I am faced with the following error:

payload
: 
{errors: [{errorType: "com.amazon.coral.service.http#HttpNotFoundException", errorCode: 400}]}
type
: 
"connection_error"
let ws = undefined;

const url = 'wss://XXXX.appsync-realtime-api.YYYY.amazonaws.com/graphql';
const apikey = 'ZZZZ';

const api_header = {
  host: 'XXXX.appsync-realtime-api.YYYY.amazonaws.com',
  'x-api-key': apikey,
};

const payload = {}; // ensuring that payload is an empty JSON object

const base64_api_header = btoa(JSON.stringify(api_header));
const base64_payload = btoa(JSON.stringify(payload));

const appsync_url = url + '?header=' + base64_api_header + '&payload=' + base64_payload;

ws = new WebSocket(appsync_url, ['graphql-ws']);

Answer №1

The host specified in the api_header is incorrect. Please use

host: 'XXXX.appsync-api.YYYY.amazonaws.com',

Important: Use appsync-api, not appsync-realtime-api.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

I'm feeling a bit lost with this API call. Trying to figure out how to calculate the time difference between the

Currently, I am working on a project for one of my courses that requires making multiple API calls consecutively. Although I have successfully made the first call and set up the second one, I find myself puzzled by the specifics of what the API is requesti ...

What could be causing the issue with setting a value for a JSON array in the following method?

Consider this piece of code that I'm currently working with: compareList[productName] = productID + ',' + productHref; console.log(productName + ' ' + productID + ' ' + productHref + ' ' + compareList.length); ...

Troubleshooting a problem with a for loop in JavaScript while developing a personalized jQuery paging

Seeking assistance with some javascript, and perhaps it's just a Friday thing, but I've hit a roadblock... I'm currently in the process of creating a custom jQuery carousel and trying to implement dynamic paging. To simplify the problem (I ...

Is there a way to modify HTML content in a UIWebView using JavaScript and then take a screenshot of the updated WebView? Perhaps with the help of CGD?

I'm currently using a UIWebView to display a webpage and I'm trying to hide certain elements on the page, then take a screenshot of it. Once I have the image, I will unhide the elements to return the webView back to normal. Here's my progre ...

Turn off the standard sign in prompt when utilizing the NTLM pass-through method in express-ntlm

In my node.js app, I am utilizing the following code with express-ntlm to obtain workstation details: var express = require('express'), ntlm = require('express-ntlm'); var app = express(); app.use(ntlm()); app.all('*', func ...

Sending HTML content as a JavaScript string literal to a component while preserving the HTML formatting

Within my array of objects, each object is passed into a child component. One value in the object is a text blob represented as a string literal, which includes HTML links that I want to preserve in the child component. Here's an example: `This is my ...

The discrepancy between the ng-model value in the controller and the input field in the HTML

In my HTML code, I have an input field that is linked to a specific value using the ng-model attribute. Initially, any changes made to this ng-model in the controller are accurately reflected in the input field. However, when I manually type something into ...

Get the docx file generated with Flask and VueJS

I've been grappling with the challenge of downloading a docx file in VueJS. Initially, I attempted to generate the file on the frontend, but it kept getting corrupted. To solve this issue, I resorted to using Flask to create the docx file, which worke ...

From turning strings into integers to numerical transformations

I need help converting the string "9876543210223023" into an integer without changing its value. I've tried using parseInt, but it always converts to 9876543210223024 which is causing issues with my validations. Can someone suggest a method to keep th ...

The URL is not appearing in the browser's address bar

Below is the code I am using for ajax requests: // JavaScript Document function createTeam() { var name=document.getElementById("name").value; if(name==null || name==""){ var div3 = document.getElementById("errorMessage"); var text ...

When using Vue, here's a trick to verify the presence of a value in a form even when the value attribute is

I am currently in the process of creating multiple forms and I need to verify if all input fields are filled out or not. Since I am utilizing data binding with the model, I am not using the value attribute. This means that when attempting to iterate throug ...

"Utilizing the useState hook to selectively update a portion of the state while keeping the remaining state unchanged

Hello there, I have a question. Is it possible to update just a portion of the state while keeping other parts the same in React? const stuff ={ 'a':'alpha', 'b':'beta' }; const [letter,setLetter]=useState(stuff); ...

Encountering an error during the installation of node js when attempting to run npm install

npm ERR! code ERESOLVE npm ERR! ERESOLVE could not resolve npm ERR! npm ERR! While resolving: <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1e687b7f7d6a327f6b6a717d717e737f76776c796937252327">[email protected]</a&g ...

Struggling to successfully deploy an Angular application on Azure

I'm currently in the process of deploying my Angular app to Azure. Utilizing VS Code and the "Azure App Service" extension. I have diligently followed this guide step by step: Upon completing the guide, I was successful in deploying the Angular app ...

Navigating through different views in Angular 2 using UI Router and ng2 routing directly from

I am currently utilizing the UI-Router ng2 and attempting to change routes after a certain function is triggered. My code snippet looks like this: SomeFunction() { if(condition){ router.navigate(['/newRouteName']); } } It's ...

What is the best method for determining the central position of a .dae file and adjusting its placement?

As I work with numerous 3D models, I have noticed that many of them are not centered properly. Is there a method to determine the dimensions (length for x, width for z, height for y) of a model and divide it by two in order to accurately position the model ...

Employing a variable for locating an element based on its class or id

Can the image source be changed using a JavaScript variable? For example, if I have a variable called "vp_active_row_count" that indicates which ball is active by number ("_a" signifies active image source). I am struggling to locate any object with the p ...

Adding numeric values to a user-friendly URL following the selection of a number

My website is primarily focused on showcasing photo galleries for visitors to browse. Users can navigate to the gallery of images from the main page, and within the gallery, they have the option to select specific photos to view. The image below illustrat ...

Enhance the impact of "dialogs" to the fullest extent or minimize it to achieve the

How can I position the minimized dialog on the bottom of the div when appending dialogs next to each other in a FB messaging system? To achieve a Facebook messaging effect, the titlebar must go down when minimizing/maximizing the dialog. Perform the follo ...

Unleashing the Power of RXJS: Discovering the Magic of connecting Events and Tapping into Executions with retrywhen

Whenever Angular attempts to establish a connection, I aim to display "Connecting". Although I can achieve this on the initial connection, I am uncertain about how to accomplish it when using retryWhen(). It is essential for me to intercept the actual exec ...