Answer the question
In order to leave comments, you need to log in
How to connect to websocket from another server?
Essence:
I am writing a small social. network with a focus on chatting. And I want to use websocket as a service so that I can balance the load. I'm trying to use https://github.com/olahol/melody as a framework for this.
deployed an application server and a websocket server on the local machine, both are obtained on the localhost, but on different ports, while trying to establish a websocket connection, the Origin header is checked with the Host in the Request, it is clear that they differ only in port.
Question: what if I want to use multiple chat services to contact one site? how to bypass the restriction?
I can rewrite the original behavior and check with a list of trusted hosts, but I don't understand what the consequences of this might be. Can you advise on this issue?
Answer the question
In order to leave comments, you need to log in
Try something like
m := melody.New()
m.Upgrader.CheckOrigin = func(r *http.Request) bool { return true }
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question