Open TaiPhamD opened 8 years ago
Hello, Openshift uses a different port for WS and WSS,
WS is on port 8000 WSS is on port 8443 (uses openshift ssl certificates, even if your application doesn't have any certificate) Been using it just fine that way :)
@AlexDias79 , you just did a redirect using that port and all just worked? Or, did you have to do something else too? I am also trying to accomplish the same thing.
Nop, no redirection needed. All i did was to inject a wss route into http router. Such as:
bind := fmt.Sprintf("%s:%s", os.Getenv("OPENSHIFT_GO_IP"), os.Getenv("OPENSHIFT_GO_PORT"))
...
http.Handle("/wsInfos", websocket.Handler(infosWSHandler))
log.Fatalln(http.ListenAndServe(bind, nil))
func infosWSHandler(ws *websocket.Conn) {
Auth := ws.Request().URL.Query().Get("Authorization")
if Auth != ApiKey {
ws.Write([]byte("Authorization failed! Provided key was: " + Auth))
return
}
ws.Write([]byte("Subscribed OK"))
ch := msgBrokerInfos.Subscribe() //nothing more than a redis subscription
defer msgBrokerInfos.Unsubscribe(ch)
So, when you use a ws or a wss into the openshift public url, the traffic will be correctly redirected as the server detects the protocol format. You don't need to define a port different than 80 for ws/wss, the openshift router itself will do that for you, for free :D
Hope it did help, Alex
What can we do in go to be able to accept port 443 requests when to load balancer will forward all data at the OPENSHIFT_GO_PORT (8080). Most of the websocket libs will reject if it detects that the client doesn't come in at port 443.