Twilio Client JS-SDK Websocket cannot establish connection

759 views Asked by At

I'm trying to connect with Twilio using the line below:

Twilio.Device.setup(token, { debug: true }); 

I already check the JWT and it is correct however the connection keeps re-establishing logs bellow:

Setting up VSP
log.ts:80 Initializing transport backoff using config:  {factor: 2, initialDelay: 100, maxDelay: 20000, randomisationFactor: 0.4}
log.ts:80 WSTransport.open() called...
log.ts:80 Attempting to connect...
log.ts:80 Closing and cleaning up WebSocket...
log.ts:80 No WebSocket to clean up.
WebSocket opened successfully.
log.ts:80 Setting token and publishing listen
log.ts:80 Received websocket close event code: 1005. Reason: 
log.ts:80 Closing and cleaning up WebSocket...
log.ts:80 Will attempt to reconnect WebSocket in 105ms
log.ts:80 Stream is offline
log.ts:80 Attempting to reconnect (retry #1)...
log.ts:80 Closing and cleaning up WebSocket...
log.ts:80 No WebSocket to clean up.
log.ts:80 WebSocket opened successfully.
log.ts:80 Setting token and publishing listen
Received websocket close event code: 1005. Reason: 
log.ts:80 Closing and cleaning up WebSocket...
log.ts:80 Will attempt to reconnect WebSocket in 244ms
log.ts:80 Stream is offline
log.ts:80 Attempting to reconnect (retry #2)...
log.ts:80 Closing and cleaning up WebSocket...
log.ts:80 No WebSocket to clean up.
log.ts:80 WebSocket opened successfully.
log.ts:80 Setting token and publishing listen
log.ts:80 Received websocket close event code: 1005. Reason: 
log.ts:80 Closing and cleaning up WebSocket...
log.ts:80 Will attempt to reconnect WebSocket in 439ms
log.ts:80 Stream is offline
log.ts:80 Attempting to reconnect (retry #3)...
log.ts:80 Closing and cleaning up WebSocket...
log.ts:80 No WebSocket to clean up.
log.ts:80 WebSocket opened successfully.
log.ts:80 Setting token and publishing listen
log.ts:80 Received websocket close event code: 1005. Reason: 
log.ts:80 Closing and cleaning up WebSocket...
log.ts:80 Will attempt to reconnect WebSocket in 1119ms
log.ts:80 Stream is offline
log.ts:80 Attempting to reconnect (retry #4)...
log.ts:80 Closing and cleaning up WebSocket...
log.ts:80 No WebSocket to clean up.
log.ts:80 WebSocket opened successfully.
log.ts:80 Setting token and publishing listen
log.ts:80 Received websocket close event code: 1005. Reason: 
log.ts:80 Closing and cleaning up WebSocket...
log.ts:80 Will attempt to reconnect WebSocket in 1639ms
log.ts:80 Stream is offline
log.ts:80 Attempting to reconnect (retry #5)...

The logs are not very helpful, it seems that the server is not responding but I'm not sure from where the server address is coming from, I'm using NGrok to connect

1

There are 1 answers

0
Jon Linnell On

It looks like your JWT was created without specifying an identity. Make sure you add a unique identity property to the options when generating the JWT.