简体   繁体   中英

Openshift Websocket custom domain

I've recently changed my openshift default domain myapp.rhcloud.com in www.myapp.com with a custom ssl certificate. The config works perfectly well until the web page ask the server for a websocket connection. I use node with socket.io and websockets enabled

I first tried:

io.connect(www.myapp.com:8443/...)

But this return an error.

So I set back the socket connection url to:

io.connect(myapp.rhcloud.com:8443/...)

But I get this error:

No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://www.myapp.com' is therefore not allowed access. 

Is there a way to allow websocket connection via a custom domain on Openshift ? Or, do I need to set up cors?

EDIT I left socket.io prefix the websocket url I do not pass the protocol to socket.io

From my understanding, WebSockets use something like this (wss instead of ws for secure)

wss://www.yourapp.com:8443

Make sure you setup openshift with your domain alias

https://www.openshift.com/kb/kb-e1096-how-to-setup-an-alias-for-your-application

When I log to https://www.myapp.com:8443/socket.io/1/ in Chrome, I get the error

Identity not verified

which is not the case on https://www.myapp.com ... after few tests and searchs I think that this error is due to the websocket preview environnement on openshift. Source ( https://www.openshift.com/blogs/paas-websockets ):

Update: There is one more known complication. When using our preview-deployment of WebSockets with HTTPS and WSS protocols, you will face self-signed certificate. That is because this environment is only temporary to give you insight into upcoming features. Once we move the new routing layer to standard ports 80 and 443, ie we move WebSockets support into production, the certificates used will be signed and valid as they are with current deployment.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM