3 Answers
- Newest
- Most votes
- Most comments
0
Updated code part. ps. the chatClientToken has expired. when I start testing i always use the latest token.
const chatClientToken = "AQICAHgDPFqoWS2jdOfTGB1Vo7NQnk0RhxoHKwei87S3M72_WgGXpV-mDgAwwUJ2UdCY15ZUAAAB0TCCAc0GCSqGSIb3DQEHBqCCAb4wggG6AgEAMIIBswYJKoZIhvcNAQcBMB4GCWCGSAFlAwQBLjARBAyJQR2ruBPj-WXSeyACARCAggGE1gSj19XcIQPV30V8wF15YmAk7Rac086esruMblXDKabrTC2UdanFCksa4aE62SeppjmhKleGNSvXUH0IajebRu4FvsflOgldfAEto8Kmum_--y7JnM0pRiefk03tXpFI9mXGhQ0AY8sbsw1gZIeg4xttXq7umQKEYef3bpsD-nC_pEcFyFPz6ilkNPVjZNaPRK_jBikhvyVImCh7x1PT3LGa8j8xhKtzGZdY1LzNgnbS9x8Q7rNmeekhkZtOaI04sMsxVIHRJlT9fGvdpkeompQo_IbUU_-Kf4YhIEROSnRSH1qSzOztUmjD33K18L5xmFnorgYCM_CsNydLMuxv8s2ygFJeOiJ-_J358y1Qmr6AdMZT-xI7lBhVftubxQ-LAwL3Hs-NPqIlq079MbH4xw1YmH8yJ56V28AKl0NfVavMWMhfwRepr2BiSUd6gQyE6rB2Y2MbQp3c4C-gMvlMAwPYMBesbTb9kCQQP-Qz2Qz5L4ZsLgJZ04kvlSVXqezFxOoNDQ!!#0";
const socket = "wss://edge.ivschat.ap-northeast-1.amazonaws.com"; // Replace “us-west-2” with supported region of choice.
const connection = new WebSocket(socket, chatClientToken);
/*
2. You can send your first message by listening to user input
in the UI and sending messages to the WebSocket connection.
*/
const payload = {
"Action": "SEND_MESSAGE",
"Content": "text message",
"Attributes": {
"CustomMetadata": "test metadata"
}
}
connection.send(JSON.stringify(payload));
answered a year ago
0
It is possible that the chat token you are using to connect to the chat room has expired. Can you provide more information about the error? What HTTP status code is returned? Here is a list of the possible errors you may receive. You might want to also decode the token using https://jwt.io to verify that it looks good and is not expired.
answered a year ago
The status shows "finished" not 200 or 400 with an empty response. I'll post my code in another comment.
Relevant content
- asked a year ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 5 months ago
Can you share your entire code please?
This is entire code I tested.
I tested the full demo code from https://github.com/aws-samples/amazon-ivs-chat-web-demo/tree/main to connect my chatroom setting. It worked. So my chatroom setting is correct. Now I need find out why my simple websocket sample didn't work!
Make sure you're not calling connection.close() and that you have a onmessage listener set up.