R
R
Roman2016-03-18 17:06:29
go
Roman, 2016-03-18 17:06:29

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

1 answer(s)
U
uvelichitel, 2016-03-18
@losaped

Try something like

m := melody.New()
m.Upgrader.CheckOrigin = func(r *http.Request) bool { return true }

Does not entail catastrophic consequences. CheckOrigin adds little security on the server side because the Origin header is easily spoofed. The browser out of the box should hold 30 ws connections with one host and 200 in total.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question