Comments (7)
the error 1000 is an error generated by cloudflare.
the bot is still sending keepalives, but if the server side (discord) sends no traffic for 2 intervals cloudflare disconnects the socket with an error 1000.
the SSL error afterwards is just D++ forced disconnect and resume by invalidating the file descriptor.
in real production use, where the guilds have real traffic, this doesn't happen ( add your invite to a busier server and you'll see).
I don't know how to prevent this as, as ive said heartbeat is being sent (stick some debug in there to find out) and it doesn't disrupt production use.
I'll have a think about what I can do to force the connection to stay open, perhaps by low level websocket pings.
from dpp.
It seems sending a low level websocket ping will prevent this (note this is not a discord API keepalive and exists in the level below):
I'll test this later and also look into the hibernation issue, however I don't run my code on anything that hibernates (only on real servers) this can mess with timers and cause issues. I'll let you know what I find out.
from dpp.
Well the trace level logging seems to include the heartbeat ACKs send by the server R: {"t":null,"s":null,"op":11,"d":null}
- and I do see those coming up, but only if there is activity on the server. Are heartbeats only send after a received package was processed instead of after a timer? That would also explain the issue after hibernation as any heartbeat should make it immediately obvious that the connection died.
Thanks for checking it out in any case :-)
from dpp.
Oh and it is not the hibernation that worries me. Disconnecting my ethernet for a minute has the same effect - and network outages do in fact happen so it would be nice for the bot to handle them correctly ^^
from dpp.
no they're sent on a timer, actually 75% of the recommended frequency so if discord says 40 seconds D++ will send them every 30 seconds.
I need to add functionality to ping the underlying websocket, websocket opcode 0x09 to expect a response of type 0x0A. Simply having activity at the application layer above (discord JSON) is not enough to satisfy cloudflare.
this is why you don't see it on other libraries as I've implemented websockets from scratch.
from dpp.
This is now fixed in 1.0.1 dev branch, commit 6cf1d27.
We needed to send a low level websocket opcode 0x9 every 30 seconds to stop cloudflare disconnecting the websocket with close code 1000. For each 0x9 we send, we receive a low level 0xa.
The attempt to send the 0x9 will also trigger the socket error routine if the connection has died.
Please let me know if there continue to be issues.
from dpp.
The commit seems to fix the issue for me. Heartbeats are send out (EDIT: acks are received) every ~30sec. After network disconnect it reconnects quickly and creates a new session as resuming it wasn't possible.
Thanks :-)
from dpp.
Related Issues (20)
- Online unit tests fail on Mac Silicone. HOT 1
- xmake dpp.lib(cluster.cpp.obj) : error LNK2019 HOT 12
- `dpp::on_voice_receive_combined` called only once per tick, with not enough samples HOT 1
- Feature Request: Configurable audio receive tick interval HOT 6
- FindSodium.cmake should support MinGW HOT 4
- Undefined behavior in dpp::populate_result when accessing non-existent headers HOT 7
- Accessing deleted timer in cluster::tick_timers HOT 1
- 1 test fails: ts_not_null() HOT 13
- dpp::cluster on_message_create callback not does not trigger when cluster is created using i_message_content intent HOT 4
- on_voice_receive, on_voice_receive_combined, and on_voice_user_talking never trigger events HOT 12
- Memory leak in request_queue when sending messages with files HOT 8
- Add an ability to tell if a message was created in a thread, or to get the thread that a message was posted in. HOT 7
- How to get a channel id on channel create? HOT 2
- set_presence() giving error 4002: decode error HOT 6
- dpp::discord_voice_client: track_meta is not cleared when stop_audio() is called HOT 3
- certain error types from discord API can cause a core dump HOT 1
- std::basic_string<uint8_t> is broken for LLVM-19 HOT 4
- Mingw integration/help HOT 1
- Add support for other encryption / decryption methods supported by discord HOT 4
- Voice channel audio from bot is choppy on Windows HOT 14
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dpp.