I am creating a demo websocket API using AWS API Gateway onConnect and onDisconnect, I have attached Lambda functions
with code like
const AWS = require('aws-sdk'); const ddb = new AWS.DynamoDB.DocumentClient(); function addConnectionId(connectionId) { return ddb.delete({ TableName: 'Chat', Key: { connectionid : connectionId, }, }).promise();} exports.handler = (event) => { console.log("Connection broken"); const connectionId = event.requestContext.connectionId; addConnectionId(connectionId).then(() => { return { statusCode: 200, body:JSON.stringify({ msg: 'connected'}) } });}
but when i call it from wscat I get 502
D:>wscat -c wss://r6e1pcpjib.execute-api.ap-south-1.amazonaws.com/development error: Unexpected server response: 502
#aws #webSocket #find-a-specialist
I tried below article but didn't find the desired output
AWS API Gateway error response generates 502 "Bad Gateway"
https://stackoverflow.com/questions/66978652/websocket-api-using-aws-uncallable April 07, 2021 at 10:06AM
没有评论:
发表评论