Hi Learn StepWise,
Welcome to Microsoft Q&A forum. Thanks for posting your query.
Here I understood that you are facing Azure Text-to-Speech Error: "Unable to contact server. StatusCode: 1006"
The 1006 error typically indicates a WebSocket connection failure between your application and Azure's Text-to-Speech service. Below are the possible causes and solutions to fix this issue:
First thing is
Check Network Connectivity & Firewall Settings:
Ensure that your network, firewall, or proxy is not blocking WebSocket connections.
Verify that port 443 (HTTPS/WebSocket) is open and accessible.
If using a corporate network, check if your IT team has any security restrictions on WebSocket traffic.
Try switching to a different network (e.g., mobile hotspot) and check if the issue persists.
Validate Azure Subscription Key & Endpoint:
If the API key used for authentication is expired, incorrect, or revoked, WebSocket connections can fail.
Confirm that you are using the correct region-specific endpoint (e.g., uksouth, eastus).
How:
Go to Azure Portal → Cognitive Services → Speech Service and check if your subscription is active.
Regenerate the key if necessary and update it in your application.
Check Azure Service Health:
There might be an outage or regional issue affecting the Text-to-Speech service.
Even if the Azure status page shows no issues, some region-specific disruptions may occur.
How:
Visit Azure Status Page and check for outages.
Try using a different region, like westeurope or eastus, if possible.
WebSocket Connection Timeouts & Keep-Alive Issues:
If the WebSocket connection is idle for too long, it may time out or be closed by the server.
Some proxies or load balancers disconnect WebSockets after a specific duration.
Solution:
Implement a keep-alive mechanism by sending periodic messages to keep the connection active.
Restart the connection if it gets disconnected unexpectedly.
Exceeding Rate Limits or Quotas:
Azure limits the number of requests per second for Text-to-Speech.
If your application sends too many requests in a short period, connections may be throttled.
Solution:
Check Azure Quotas & Limits in the Azure Portal under Speech Services.
Reduce the number of concurrent requests or implement rate-limiting in your application.
Browser or Client-Side Issues:
Some browser settings or outdated clients may not handle WebSocket connections properly.
Ad blockers, browser extensions, or security tools could also interfere with the connection.
Solution:
Test the Text-to-Speech service using a different browser or device.
Disable ad blockers or VPNs and check if the connection works.
Hope this helps. Do let us know if you any further queries.
------------
If this answers your query, do click Accept Answer
and Yes
for was this answer helpful.
Thank you.