Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Websocket port 443 for WSS:// #39

Open
TaiPhamD opened this issue Oct 16, 2016 · 3 comments
Open

Websocket port 443 for WSS:// #39

TaiPhamD opened this issue Oct 16, 2016 · 3 comments

Comments

@TaiPhamD
Copy link

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.

@AlexDias79
Copy link

AlexDias79 commented Nov 11, 2016

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 :)

@siredwin
Copy link

@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.

@AlexDias79
Copy link

AlexDias79 commented Feb 21, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants