Closed abovethewater closed 3 years ago
Having had a little play, it is indeed due to the poor support of websockets on OpenShift.
Changing line 16 of layout.ejs to that effect works
var port = 8000;
if (location.protocol === 'https:') {
port = 8443;
}
var socket = io.connect(location.protocol + '//' + location.hostname + ':' + port);
However, that results in a cross-domain failure, as no CORS headers on the websocket response.
Accessing the site via the same port (i.e. http://xxx.rhcloud.com:8000/ or https://xxx.rhcloud.com:8443) works fine, but is ugly as hell.
Had the same issue while testing just now, here's what I did at line 16 of layout.ejs:
var port = 8000,
protocol = 'ws://',
isSecure = false;
if (location.protocol === 'https:') {
port = 8443;
protocol = 'wss://';
isSecure = true;
}
var socket = io.connect(protocol + 'yourappname-yourdomain.rhcloud.com:' + port, {secure: isSecure});
socket = io.connect(HOST_REMOTE, {
transports: ['xhr-polling']
});
I had the same issue on OpenShift. Its been resolved by defining transport types
I get the following error in the console: WebSocket connection to 'ws://xxx.rhcloud.com/socket.io/1/websocket/IuKwIESH_-nUfYJbr_dA' failed: Error during WebSocket handshake: Unexpected response code: 502
Not sure if this error actually affects anything as it is likely falling back to polling.
Should I be concerned about this error? Can websockets be enabled by using port 8000 / 8443 as per https://www.openshift.com/blogs/paas-websockets