I have small HTTP + WebSocket server hosted on Amazon VPS. Index.html has JS code to connect WebSocket server and exchange data with it. When I connect my server directly using public IP or domain name - everything works fine.
However I don't want this server to be public, so I configured OpenVPN to connect to this server privately.
Sometimes everything works as expected over OpenVPN and when I enter local (inside VPN) servers IP address in my browser (Chrome or Opera) it succesfully loads index.html, connects my WebSocket server and succesfully exchanges data via WebSocket connection. But sometimes (or some days) 1 second after Websocket connection is established it is closed by browser with error code 1006 and without any description. My script tries to reconnect WebSocket 1 second after this, but result is the same all the time.
I can't figure out why sometimes everything is working and sometimes I can't use WebSocket over OpenVPN for several hours.
Can somebody describe why error 1006 occures when using WebSocket over OpenVPN and how to eliminate it by coding or reconfiguring Chrome, Opera or OpenVPN?