Merubokkusu / Discord-S.C.U.M

A Discord API Wrapper for Userbots/Selfbots written in Python.
MIT License
581 stars 171 forks source link

Websocket closes #89

Open splexas opened 3 years ago

splexas commented 3 years ago

Hey, im trying to run a selfbot, but after entering the heartbeat, the websocket closes, and the connection drops, i ran it with a different token, everything was fine. Any ideas what kind of a problem is this?-


arandomnewaccount: What error did you get when your first selfbot disconnected from the gateway? Did it try to reconnect or simply close?

kadnan commented 2 years ago

My script also ends but I get no error at all. How do I figure it whether it's a Websocket issue or something else?

jornx commented 2 years ago

I have the same problem, I get this error:

Unhandled exception in thread started by <bound method GatewayServer._heartbeat of <discum.gateway.gateway.GatewaySe rver object at 0x7f64db625048>> Traceback (most recent call last): File "/home/jorn/.local/lib/python3.7/site-packages/discum/gateway/gateway.py", line 205, in _heartbeat self.send({"op": self.OPCODE.HEARTBEAT,"d": self.sequence-1 if self.sequence>0 else self.sequence}) File "/home/jorn/.local/lib/python3.7/site-packages/discum/gateway/gateway.py", line 210, in send self.ws.send(json.dumps(payload)) File "/home/jorn/.local/lib/python3.7/site-packages/websocket/_app.py", line 191, in send "Connection is already closed.") websocket._exceptions.WebSocketConnectionClosedException: Connection is already closed.


arandomnewaccount: idk, I need more info (like what your script is doing) in order to replicate your issue on my end

Luhari commented 2 years ago

I have the same error but with the difference that the bot has been running for months without any changes at the code and today between 2 days ago and today, the bot showed that error. So I don't think it's related to what the script is doing, as my last commit and push was last month and have been working as intended until these 2 lasts days...

In my case, the bot is hosted in heroku, and its logs are the following:

2021-09-09T00:03:12.181529+00:00 app[worker.1]: Traceback (most recent call last):
2021-09-09T00:03:12.181593+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.9/site-packages/discum/gateway/gateway.py", line 205, in _heartbeat
2021-09-09T00:03:12.182233+00:00 app[worker.1]:     self.send({"op": self.OPCODE.HEARTBEAT,"d": self.sequence-1 if self.sequence>0 else self.sequence})
2021-09-09T00:03:12.182264+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.9/site-packages/discum/gateway/gateway.py", line 210, in send
2021-09-09T00:03:12.185172+00:00 app[worker.1]:     self.ws.send(json.dumps(payload))
2021-09-09T00:03:12.185192+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.9/site-packages/websocket/_app.py", line 188, in send
2021-09-09T00:03:12.185347+00:00 app[worker.1]:     raise WebSocketConnectionClosedException(
2021-09-09T00:03:12.185398+00:00 app[worker.1]: websocket._exceptions.WebSocketConnectionClosedException: Connection is already closed.

arandomnewaccount: weird, I haven't been able to reproduce this error. Try the development branch of discum: https://github.com/Merubokkusu/Discord-S.C.U.M/tree/development

Luhari commented 2 years ago

Weird. Downgrading to development branch stopped the socket error.

python3.7 -m pip install https://github.com/Merubokkusu/Discord-S.C.U.M/archive/development.zip


arandomnewaccount: dev branch back then is in the master branch so, just install from master branch as usual

mohdsabahat commented 2 years ago

I happened to face the same issue. Although i was just testing the bot and running it locally and it closed the connection after about 10 minutes.. Here are the last few lines i found in log file!

[gateway] < {'t': 'SESSIONS_REPLACE', 's': 3, 'op': 0, 'd': [{'status': 'online', 'session_id': 'THE_SESSION_ID', 'client_info': {'version': 0, 'os': 'android', 'client': 'web'}, 'activities': []}]} [gateway] < {'t': 'PRESENCE_UPDATE', 's': 4, 'op': 0, 'd': {'user': {'id': '54035**************'}, 'status': 'offline', 'last_modified': 1644561718466, 'client_status': {}, 'activities': []}} [gateway] close status code: 1000 [gateway] close message: [gateway] websocket closed [gateway] Connection forcibly closed using close function.