How to upgrade the https connection to websocket?

I want to simulate logging in to a game server, the normal login request I grabbed from game client through Fiddler like these:

Connection: Upgrade
Pragma: no-cache
Cache-Control: no-cache
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36
Upgrade: websocket
Sec-WebSocket-Version: 13
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8
Sec-WebSocket-Key: y3lRQIYateSC7y2U56KcTw==
Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits

After that, the communication between the game client and the server is based on websocket.
I found that tokio-tungstenite might be what I need, but the official examples all directly establish the ws connection, I don't know how to connect to that https server first and then upgrade the connect to websocket and use the upgraded connection.
Any help is appreciated,thanks. :grinning:

All WebSocket connections are made by HTTP upgrade. Thus, any client will do.

1 Like

I didn't know much about websocket before, now it works, thank you for your reply!

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.