ivs chat websocket connect failed.

0

I followed the instructions to create a chatroom and token, and used the sample code to connect to the chatroom using WebSocket, but I got a connection error.

my lab is hosting a sample file ivs-chatroom.html on my ec2 server. And tried to connect to wss://edge.ivschat.ap-northeast-1.amazonaws.com failed.

profile picture
N Wang
질문됨 8달 전310회 조회
3개 답변
0
수락된 답변

I added .onopen event, then it worked.

profile picture
N Wang
답변함 7달 전
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));

browser console log browser console network log with header

profile picture
N Wang
답변함 7달 전
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.

profile picture
답변함 8달 전
  • The status shows "finished" not 200 or 400 with an empty response. I'll post my code in another comment.

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠