Twilio Programmable Chat throwing Can't connect to twilsock

淺唱寂寞╮ 提交于 2020-01-24 19:33:07

问题


When I'm trying to use the programmatic chat I'm constantly getting this error

Error: Can't connect to twilsock
at t (twilio-chat.min.js:204)
at t (twilio-chat.min.js:204)
at new t (twilio-chat.min.js:204)
at e.value (twilio-chat.min.js:204)
at t.value (twilio-chat.min.js:204)
at twilio-chat.min.js:204
at t.<anonymous> (twilio-chat.min.js:204)
at twilio-chat.min.js:168
at t.a.emit (twilio-chat.min.js:168)
at t.value (twilio-chat.min.js:175)

I followed all the instruction for the repo I'm testing on. I generate the token. So not sure what is wrong. I understand something is wrong when generating the token. Can anyone tell me what identity needs to be passed? I created the test user in the service from the Twilio console but still it's not working.


回答1:


Twilio developer evangelist here.

I believe you might be using test credentials to generate your access token. With Programmable Chat you cannot use test credentials, they are only to be used to fake sending messages, buying numbers and making phone calls.

Please try generating your access token again but with live credentials available in your Twilio console.




回答2:


I'd just like to add I ran into this error and while my problem turned out to be when generating the token, it wasn't clear that was the problem (it was generating a valid JWT token, with valid, live credentials).

I didn't realize I was using an object instead of a string (ObjectId) for the identity, and so just adding a .toString() for it made the error go away (something like token.identity = user._id.toString(); in my case).

Very obscure, so hopefully this will help someone else.

Also, note the Chat.create(token) or Twilio.Chat.Client.create(token) will expect token to be the output of token.toJwt() from the backend, as sending the JSON token doesn't throw an error or work.




回答3:


I had this problem as well.

The SIDs were not spelled correctly in my case. Double check to make sure that you are passing the right parameters when getting the token through the rest api.

Silly mistake but i did spend some time figuring it out.



来源:https://stackoverflow.com/questions/54503631/twilio-programmable-chat-throwing-cant-connect-to-twilsock

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!