#Can't connect web socket with tungstenite
16 messages · Page 1 of 1 (latest)
@vague valve https://github.com/snapview/tungstenite-rs#features native-tls is probably the one you want.
pub fn connect() -> Self {
let (socket, _) = tungstenite::connect(Request::builder().uri(DISCORD_WS).body(()).unwrap())
.expect("Couldn't connect to discord gateway");
let mut gateway = Self {
socket,
heartbeat_interval: 0,
};
let hello = gateway.receive_packet::<HelloPacket>();
assert_eq!(hello.op, HELLO_OPCODE);
gateway.heartbeat_interval = hello.d.unwrap().heartbeat_interval;
gateway
}
I'm trying to connect to the discord gateway (WebSocket) with tungstenite
But i'm getting this error
never used websockets, the only thing I can tell you is a header is invalid idk
try to use Url::parse like in their examples instead of Request::builder
@placid stag now i get this error
error 400
btw discord uses wss instead of ws
is that the problem?
wss://gateway.discord.gg/?v=10&encoding=json
I have no idea, sorry