Closed kyun closed 4 years ago
Hey,
I think you may be missing something with your AWS Lambda code. Generally, disconnect
happens in a separate handler, but I'm not sure what exactly you're doing.
In any event, on the client-side, what Sockette does is exactly the same as the following code:
function socketHandler(uid){
const url = `wss://MY_API_GATEWAY_URL.execute-api.ap-northeast-2.amazonaws.com/dev?groupId=GROUP_ID&uid=${uid}`;
return new WebSocket(url);
}
const wss = socketHandler('123');
setTimeout(() => {
// some time later...
wss.close(1000);
}, 3000);
Sockette doesn't add/change anything in this process; see here
If the above still fails for you, either your Lambda code needs adjusting or the browser API doesn't do what you're expecting – which, IMO, still means that your Lambda needs adjusting.
Hope that helps! Keep me posted
I built up the WebSocket server with
AWS API Gateway
.and, I am connecting this with
AWS Lambda
.It works well when I connect, but when I disconnect, it doesn't work well.
My React Client Code
My Lambda Code
I'd like to use WebSocket URL with
queryParameters
even I disconnect.If I missed something, please reply me.