Closed pluiedev closed 3 years ago
Hello, and thanks for opening an issue! As this is the first time you've created an issue on this repository, we'd just like to offer you a warm welcome to the project, and the following pointers:
Please provide as much information as possible when asking a question, reporting a problem, or submitting a feature request. This will help us to address your issue quickly and efficiently. If you forgot to add some information, no worries - feel free to edit the issue and add anything you missed!
Thanks for contacting us! If you have any further questions, please feel free to join us on Discord in the #dev-kotdis
channel (or #kordex-discussion
for Kord Extensions projects), or to contact a staff member directly.
If Kord provides something for this, then I suspect it should be pretty easy to expose that, right? Can't imagine this being difficult.
Kord allows setting httpClient
in KordBuilder
as long as it could install Websockets
and JsonFeature
Kord allows setting
httpClient
inKordBuilder
as long as it could installWebsockets
andJsonFeature
Yeah that's what I did with the workaround. If I can do that with Kordex without duplicating a lot of code that would be good
Instead of providing a direct abstraction for this, I'm adding a kord
DSL function to the ExtensibleBotBuilder
class. This will allow you to directly run code against the KordBuilder
, which I think is a more future-proof solution for allowing users to customize Kord's behaviour.
This will be available in the next snapshot, but I'm hoping to get a release out soon!
Also: Nice.
Summary
Currently I have a (very) niche problem whenever I want to test or run my bot -- turns out that Kord defaults to use CIO for its default HTTP engine for Ktor, which has some bizarre issues with my proxy service that made the outward packets not handled by the proxy service. After some research I found out that my proxy is running under SOCKS, while CIO and Apache engines only support HTTP proxies for some godforsaken reasons.
After some more research I found out that Ktor also supports the Java HTTP Client, which fully supports SOCKS proxies and after using some (concerning) hacks I was able to get it to work.
Current Behaviour
The HTTP client is hardwired to use CIO, which is undesirable for my needs as mentioned above.
Preferred Behaviour
Allow a field to be exposed in
ExtensionBotBuilder
, either of typeHttpClient
orHttpClientEngineFactory<*>
to set customize the HTTP client or its engine. The latter may require modifying Ktor, but from what I can see, modifyingHttpClient
is perfectly acceptable within Ktor's APIs, as aKordBuilder
can be specified to take a custom client, while all of the normal settings required to make it work still applies.Suggestions
I noticed that only a selection of settings are customizable in
ExtensionBotBuilder
, presumably due to encapsulation concerns. But in addition to the ability to customize HTTP clients (which is arguably niche), I don't see why theKordBuilder
cannot be customized with a configure function (likeKordBuilder.() -> Unit
). That would solve the entire problem, and may even prevent future problems like this showing up.Media
Current workaround
Current workaround for this issue; some parts are redacted and/or deleted