I’m using gorilla web socket and I want to run it locally , I mean with the following chrome client or other recommended tool …when I run into debug mode I got error
I use
"github.com/gorilla/websocket"
var upgrader = websocket.Upgrader{
ReadBufferSize: 1024,
WriteBufferSize: 1024,
}
upgrader.CheckOrigin = func(r *http.Request) bool { return true }
c, err := upgrader.Upgrade(w, r, nil)
if err != nil {
log.Print("upgrade:", err)
return
}
When I run the following url in chrome or web socket client I got error
websocket: not a websocket handshake: 'upgrade' token not found in 'Connection' header
localhost:8081/mypath
and I want to run it
ws://localhost:8081/mypath
and provide token for local simulation, how I can do it ?
To check it I use Simple WebSocket Client of chrome. any other client will be helpful
EDIT:
when I try it in the chrome console I got the following error:
VM42:164 Refused to connect to 'ws://localhost:8081/mypath' because it violates the following Content Security Policy directive: "connect-src 'self' uploads.github.com status.github.com collector.githubapp.com api.github.com www.google-analytics.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com wss://live.github.com
Browsers do not use the WebSocket protocol when fetching a web page for display. Code is required to use a WebSocket endpoint from a browser.
The Gorilla package includes examples showing how to connect from a browser (the chat and command examples are good places to start).
You can can connect to a WebSocket endpoint using the browser console:
> ws = new WebSocket("ws://localhost:8080/mypath")
> ws.onmessage = function(ev) { console.log(ev.data) }
> ws.send("hello")