I am trying to connect to a websocket in Golang using github.com/gorilla/websocket library but it's failing with a bad handshake.
Golang code :
c, resp, err := websocket.DefaultDialer.Dial(WEBSOCKET_ENDPOINT, nil)
if err != nil {
fmt.Println(resp.Status)
fmt.Println(err)
}
_ = c
Output :
200 OK
websocket: bad handshake
I also tried connecting to the same socket in python using socketio and it works.
Python code:
import socketio
sio = socketio.Client()
sio.connect(WEBSOCKET_ENDPOINT, transports = 'websocket')
@sio.event
def connect():
print("I'm connected!")
Output :
I'm connected!