Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS API Gateway Websocket UnknownError

We are experiencing an error when doing a SDK postToConnection() call as a promise, full error details given below. Other calls in the same function with a different connection ID happen successfully. Expected 410 connection errors are happening correctly and in milliseconds and are being handled gracefully.

This error then takes anything between 40 seconds to well over a minute to return, which causes it to always cause 'endpoint request timeout' errors in the Web socket API as it has a 30 second maximum request timeout. Has anybody experienced this issue before and/or any solution implemented? Any ideas to fix the issue will be highly appreciated, thanks.

UnknownError: Network error communicating with endpoint at Object.extractError (/opt/nodejs/node_modules/aws-sdk/lib/protocol/json.js:51:27)

like image 239
krishna Avatar asked Apr 15 '19 11:04

krishna


People also ask

What is a WebSocket API in API gateway?

A WebSocket API in API Gateway is a collection of WebSocket routes that are integrated with backend HTTP endpoints, Lambda functions, or other AWS services. You can use API Gateway features to help you with all aspects of the API lifecycle, from creation through monitoring your production APIs.

What are the errors common to the API actions of AWS?

This section lists the errors common to the API actions of all AWS services. For errors specific to an API action for this service, see the topic for that API action. You do not have sufficient access to perform this action. The request signature does not conform to AWS standards.

How to check if AWS endpoint is failing or not?

For Console failures, you can always check on client side by going to Developer Tools provided by browsers. Typically F12 key --> Networktab, replicate the issue and see which AWS Endpoint gave error or go to Consoletab and see any JavaScript errors logged.

Are WebSocket routes two-way or one-way communication?

WebSocket routes can be configured for two-way or one-way communication. If a route has a route response, it is configured for two-way communication. Otherwise, it is configured for one-way communication.


1 Answers

are you trying to use postToConnection inside the connect handler? The websocket connection is only created after the connect handler has returned statusCode 200. You should not use postToConnection inside connect handler.

like image 64
ascendzor Avatar answered Nov 17 '22 18:11

ascendzor