import websocket #pip install websocket-client
import json
import threading
import time
token_file = open("token.txt", "r")
token_read = token_file.read()
token_list = token_read.split()
token_file.close()
print(token_list)
def send_json_request(ws, request):
ws.send(json.dumps(request))
def recieve_json_response(ws):
response = ws.recv()
if response:
return json.loads(response)
def heartbeat(interval, ws):
print( Heartbeat begin )
while True:
time.sleep(interval)
heartbeatJSON = {
"op": 1,
"d": "null"
}
send_json_request(ws, heartbeatJSON)
print("Heartbeat sent")
for index , v in enumerate(token_list):
ws = websocket.WebSocket()
ws.connect( wss://gateway.discord.gg/?v=6&encording=json )
event = recieve_json_response(ws)
heartbeat_interval = event[ d ][ heartbeat_interval ] / 1000
threading._start_new_thread(heartbeat, (heartbeat_interval, ws))
pis=1
payload = {
op : 2,
"d": {
"token": v,
"properties": {
"$os": "windows",
"$browser": "chrome",
"$device": pc
}
}
}
try:
send_json_request(ws, payload)
except:
index += 1
print(index, "error")
Exception ignored in thread started by: <function heartbeat at 0x00000236C458D3A0>
Traceback (most recent call last):
File "C:UserspcDesktop estwebsoket.py", line 38, in heartbeat
send_json_request(ws, heartbeatJSON)
File "C:UserspcDesktop estwebsoket.py", line 16, in send_json_request
ws.send(json.dumps(request))
File "C:UserspcAppDataLocalProgramsPythonPython39libsite-packageswebsocket\_core.py", line 282, in send
return self.send_frame(frame)
File "C:UserspcAppDataLocalProgramsPythonPython39libsite-packageswebsocket\_core.py", line 310, in send_frame
l = self._send(data)
File "C:UserspcAppDataLocalProgramsPythonPython39libsite-packageswebsocket\_core.py", line 514, in _send
return send(self.sock, data)
File "C:UserspcAppDataLocalProgramsPythonPython39libsite-packageswebsocket\_socket.py", line 175, in send
return _send()
File "C:UserspcAppDataLocalProgramsPythonPython39libsite-packageswebsocket\_socket.py", line 152, in _send
return sock.send(data)
File "C:UserspcAppDataLocalProgramsPythonPython39libssl.py", line 1173, in send
return self._sslobj.write(data)
ConnectionAbortedError: [WinError 10053]
works fine for some time But I get an error and the connection is closed What did I do wrong?