The websockets Discord API expects clients to send a “heartbeat” every X milliseconds (it’s around a minute) to keep the connection alive. How can I (using WebSockets.jl or the HTTP.WebSockets
module) send a websocket message containing the heartbeat in fixed intervals while still receiving events and also sometimes sending other messages?
Did you end up figuring this out? Thanks
using HTTP.WebSockets
uri = "wss://bla.bla"
heartbeatJSON = ""
WebSockets.open(uri) do socket
@sync begin
@async for msg in socket
println(msg)
end
@async begin
sleep(30)
while !WebSockets.isclosed(socket)
send(socket, heartbeatJSON)
sleep(30)
end
end
end
This should work.