Abel Lamesgen
Abel Lamesgen

Reputation: 326

Can't connect to twilsock while creating Client

i am using Twilio with react and when i create the client using this code

this.chatClient = new Chat(this.state.token);

but i keep geting this error

TransportUnavailableError: Can't connect to twilsock
at Upstream.send (http://localhost:3000/static/js/1.chunk.js:96516:31)
at TwilsockClient.post (http://localhost:3000/static/js/1.chunk.js:94626:28)
at http://localhost:3000/static/js/1.chunk.js:88943:33
at Retrier.<anonymous> (http://localhost:3000/static/js/1.chunk.js:88882:11)
at Retrier.push../node_modules/events/events.js.EventEmitter.emit (http://localhost:3000/static/js/1.chunk.js:25082:17)

Thanks in advance

Upvotes: 3

Views: 2685

Answers (2)

David H
David H

Reputation: 11

Just in case anyone arrived at this post who wasn't having network/firewall issues.

I was getting this error periodically using Twilio Sync. It was caused by an invalid token or in my case when the token expired after a period of time. You need to handle refreshing the token, similar to this:

_syncClient = new SyncClient(getNewToken());

_syncClient.on('tokenAboutToExpire', function() {
       _syncClient.updateToken(getNewToken());
});

Upvotes: 1

Abel Lamesgen
Abel Lamesgen

Reputation: 326

The issues were between my device and Twilio. so I run the test bellow to find out what was the issue for me it was a network/firewall issue. fixed that and now it is working

https://networktest.twilio.com 

Upvotes: 2

Related Questions