Closed ghost closed 4 years ago
@XjCyan1de а можно на код посмотреть?
Ошибка происходит раз в сутки-две
@XjCyan1de к сожалению, как раз эта часть кода и не нужна — я хотел глянуть на инициализацию VkClient
, которой как раз там не видно.
Я подозреваю, что скорее всего проблема в неустановленных таймаутах при инициализации HttpClient
.
Но также по своему опыту могу добавить, что 503/504 и схожие ошибки апи ВК может возвращать довольно часто. Могу предложить еще попробовать добавить логгинг и увидеть точно, с каким http кодом и какой респонс приходит, и откуда конкретно — тогда станет яснее, просто ли проблема в том, что у лонгполла таймаут больше, чем у http-клиента, или же проблемы на стороне сервера ВК (что вполне вероятно тоже может быть).
val VK_CLIENT = VkApiClient(VK_ID.toInt(), VK_TOKEN, VkApiClient.Type.Community, VkSettings(VkOkHttpClient()))
@XjCyan1de https://vksdk.github.io/vk-sdk-kotlin/http-clients/#abstract-http-client-configuration и https://vksdk.github.io/vk-sdk-kotlin/http-clients/#use
Советую установить read timeout и connect timeout. Если не поможет — сделать подробное логгирование (см. мой предыдущий комментарий). Если проблема окажется в сервере ВК, то следует попробовать обрабатывать ошибку самому, если без копания в коде библиотеки обработать не получится и бот все равно останавливается — тогда уже я буду разбираться.
Поставил в Http клиенте таймаут на Int.MAX_VALUE, проблем больше не было) Видимо сервер вк залагивает и превышает дефолтный таймаут 30 секунд
@XjCyan1de 30 секунд должно быть достаточно, ну минуту можно поставить, Int.MAX_VALUE
не стоит :)
Если появятся еще проблемы — welcome.
Раз в сутки примерно вылезает это исключение, причём авторестарт стоит, но он не реагирует на это. Просто зависает