Jinal Shah
Jinal Shah

Reputation: 315

Twilio Programmable Chat throwing Can't connect to twilsock

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.

Upvotes: 2

Views: 4429

Answers (4)

Make sure to use all the corrret ones

   $TWILIO_CHAT_SERVICE_SID = 'IS7XXXXXXXXXXXXXXXXXXXXX';
   $accountSid = 'ACXXXXXXXXXXXXXXX';
   $apiKeySid = 'SKXXXXXXXXXXXXXXX';
   $apiKeySecret = 'F5XXXXXXXXXXXXXXX';

That casusethe Error

Upvotes: 0

eazymakaveli
eazymakaveli

Reputation: 48

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.

Upvotes: 0

Bruno Bernardino
Bruno Bernardino

Reputation: 496

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.

Upvotes: 1

philnash
philnash

Reputation: 73027

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.

Upvotes: 5

Related Questions