twilio / twilio-taskrouter.js

JS SDK v2 for Twilio's TaskRouter skills based routing system.
https://www.twilio.com/docs/taskrouter
Other
23 stars 32 forks source link

WebSocket Connection Failure in Sample App #117

Closed jcousins-eonnext closed 3 months ago

jcousins-eonnext commented 3 months ago

Environment variables were not correct


Description

I'm attempting to use the Twilio TaskRouter.js sample app but am encountering a persistent WebSocket connection error to 'wss://[invalid URL removed]...'. The worker immediately disconnects afterward.

Steps to Reproduce

  1. Clone the repository git clone https://github.com/twilio/twilio-taskrouter.js
  2. Choose correct directory and install dependencies cd twilio-taskrouter.js/sample-app && yarn
  3. Run the app yarn dev
  4. Supply correct values for environment variables.
  5. Start the sample application.

Observed Behavior

[2024-03-08T18:35:40.643Z] Disconnecting websocket
worker.client.tsx:80 [2024-03-08T18:35:40.644Z] Received Event: 'disconnected' from Signaling layer for Worker %s. %s  {message: 'SDK Disconnect'}
worker.client.tsx:80 [2024-03-08T18:35:40.644Z] Unsubscribing from TaskRouter events ... 
log-context.tsx:26 disconnected--Worker is disconnected. reason: {"message":"SDK Disconnect"}
log-context.tsx:26 ======================================================
log-context.tsx:26 Token generated
log-context.tsx:26 <valid_jwt_token>
log-context.tsx:26 Initializing Worker with the new token
worker.client.tsx:69 [2024-03-08T18:35:40.647Z] Subscribing to Signaling events .... 
worker.client.tsx:69 WebSocket connection to 'wss://event-bridge.stage-us1.twilio.com/v1/wschannels?token=<token>&closeExistingSessions=true&clientVersion=2.0.3' failed: 
worker.client.tsx:69 [2024-03-08T18:36:10.676Z] WebSocket error occurred:  
Event {isTrusted: true, type: 'error', target: WebSocket, currentTarget: WebSocket, eventPhase: 2, …}
index.window.js:4 [2024-03-08T18:36:10.678Z] Received Event: 'error' from Signaling layer for Worker %s. 
log-context.tsx:26 error--Worker errored out. error: {}
worker.client.tsx:127 [2024-03-08T18:36:10.679Z] Disconnecting websocket
worker.client.tsx:127 [2024-03-08T18:36:10.679Z] Received Event: 'disconnected' from Signaling layer for Worker %s. %s  
{message: 'SDK Disconnect'}
worker.client.tsx:127 [2024-03-08T18:36:10.679Z] Unsubscribing from TaskRouter events ... 
log-context.tsx:26 disconnected--Worker is disconnected. reason: {"message":"SDK Disconnect"}

Expected Behaviour

The sample app should establish a WebSocket connection to Twilio TaskRouter and maintain worker availability.

Attempted Troubleshooting

Environment

Operating System: macOS Sonoma 14.3.1 Browser: Chrome Version 122.0.6261.112 Node.js Version: v18.19.1 Twilio TaskRouter JS SDK Version: v2.0.3

Request

I'd greatly appreciate any help on debugging this issue.

Could it be related to the sample app, or are there other troubleshooting steps I should consider?