I had previously tried setting up Nginx with a Droplet but wasn’t successful. I deleted the Droplet and then deployed my app from the Apps service. The app is live but I’m getting the error:
“WebSocketClient.js:13 WebSocket connection to ‘wss://website.io:8080/ws’”.
Is it possible that some bad configuration from the Droplet and Nginx was leftover and is causing this conflict?
Thanks
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Accepted Answer
Hi there,
I think that when instantiating the web socket, you should not add the port as it is not publicly exposed on the App Platform.
Instead you should do something like this:
const protocol = window.location.protocol.includes('https') ? 'wss': 'ws'
const ws = new WebSocket(`${protocol}://${location.host}/ws`);
Here is a great step by step tutorial that covers the whole process specifically for the App Platform:
https://docs.digitalocean.com/tutorials/app-deploy-websockets/
UPDATE:
It looks like that this is a standard thing for some React apps:
What you have to do is to define an environment variable in your app platform and define the WDS_SOCKET_PORT
variable and set it to 443
rather than the default value.
You can check that this would already work by visiting your website and in the web console run:
new WebSocket('wss://domain.io/ws');
Let me know if you have any questions!
Best,
Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.