twilio / twilio-chat-demo-js

Programmable Chat API Demo Application for JavaScript
BSD 3-Clause "New" or "Revised" License
90 stars 94 forks source link

Client.create() never resolves if the WebSocket fails #49

Closed schontz closed 2 years ago

schontz commented 4 years ago

(This is an issue with twilio-chat, not the demo, but I couldn't find a place to report bugs on the SDK directly.)

Using Client.create() never resolves if the WebSocket fails. The easiest way to test this is to disconnect wifi/lan and run the following:

window.awaitingClient = Client.create(token).then(client => {
  console.log('client:', client);
});

If you check the console, you'll eventually see:

websocketchannel.js:16 WebSocket connection to 'wss://tsock.us1.twilio.com/v3/wsconnect' failed:
Error in connection establishment: net::ERR_NAME_NOT_RESOLVED

But if you check the promise, it is eternally pending:

> awaitingClient
Promise {<pending>}

I expect that the promise would be rejected if the websocket fails.

schontz commented 4 years ago

Interestingly, if you restore your connection at some point in the future (in my case, 10 minutes later), it will connect and resolve. So perhaps it is good that it is still pending, but there is no way to get insight into the status of things in the meantime.

jeanverster commented 4 years ago

I'm having this same issue! I have a react-native app in which I'm trying to initiate the twilio chat client, but each time I try run the create method it just hangs and the memory usage of my app goes through the roof.. I'm at a loss as to what it could be, I've run the twilio network test at https://networktest.twilio.com and connectivity is all green. Did you manage to resolve this?