I deployed a websocket server on an AWS EC2 instance. I am able to connect to this websocket without any issues from a Python script (using websocket.create_connection), but I get a 403 error when running the Javascript line var ws = new Websocket(.....)
in Chrome: Error during WebSocket handshake: Unexpected response code: 403
.
I made sure to change the security group on the EC2 instance to allow all inbound and outbound traffic.
All suggestions appreciated!
EDIT: Figured out what was going on here. It was an issue with the default origin check function in my Go websocket server.
This was a server-side issue with the gorilla/websocket package. Had to add this CheckOrigin function:
var upgrader = websocket.Upgrader{
ReadBufferSize: 1024,
WriteBufferSize: 1024,
CheckOrigin: func(r *http.Request) bool {return true},
}