18
Мар
2017

Нагрузка на LongPoll сервер VK API


из-за большой нагрузки, пару-тройку сотен в минуту, (да-да, она действительно такая и даже больше, в зависимости от времени суток), LongPoll сервер ВК выдает ошибку:

{"failed":1,"ts":<new_ts>}

Означает эта ошибка следующее:

история событий устарела или была частично утеряна, приложение может получать события далее, используя новое значение ts из ответа.


Бот работает минуты 2-3, затем начинают выпадать ошибки:

    at com.vk.api.sdk.httpclient.HttpTransportClient.post(HttpTransportClient.java:170)
    at com.vk.api.sdk.client.ApiRequest.executeAsString(ApiRequest.java:95)
    at com.vk.api.sdk.client.ApiRequest.execute(ApiRequest.java:59)
    at LongPollHandler.run(LongPollHandler.java:180)
Caused by: java.net.SocketTimeoutException: connect timed out
    at java.net.DualStackPlainSocketlmpl.waitForConnect(Native Method)
    at java.net.DualStackPlainSocketlmpl.socketConnect(Unknown Source)
    at java.net.AbstractPlainSocketlmpl.doConnect(Unknown Source)
    at java.net.AbstractPlainSocketlmpl.connectToAddress(Unknown Source)
    at java.net.AbstractPlainSocketlmpl.connect(Unknown Source)
    at java.net.PlainSocketlmpl.connect(Unknown Source)
    at java.net.SocksSocketlmpl.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSL ConnectionSocketFactory.java:337)
    at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect (DefaultHttpClientConnectionOperator.java:141)
    ... 15 more

com.vk.api.sdk.exceptions.ClientException: I/O exception
    at com.vk.api.sdk.client.ApiRequest.executeAsString(ApiRequest.java:98)
    at com.vk.api.sdk.client.ApiRequest.execute(ApiRequest.java:59)
    at LongPollHandler.run(LongPollHandler.java:180)

java.net.SocketTimeoutException: timeout
        at okio.Okio$4.newTimeoutException(Okio.java:227)
        at okio.AsyncTimeout.exit(AsyncTimeout.java:284)
        at okio.AsyncTimeout$2.read(AsyncTimeout.java:240)
        at okio.RealBufferedSource.indexOf(RealBufferedSource.java:325)
        at okio.RealBufferedSource.indexOf(RealBufferedSource.java:314)
        at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:210)
        at okhttp3.internal.http.Http1xStream.readResponse(Http1xStream.java:185)
        at okhttp3.internal.http.Http1xStream.readResponseHeaders(Http1xStream.java:126)
        at okhttp3.internal.http.HttpEngine.readNetworkResponse(HttpEngine.java:707)
        at okhttp3.internal.http.HttpEngine.access$200(HttpEngine.java:81)
        at okhttp3.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:692)
        at okhttp3.internal.http.HttpEngine.readResponse(HttpEngine.java:547)
        at okhttp3.RealCall.getResponse(RealCall.java:242)
        at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:199)
        at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:161)
        at okhttp3.RealCall.execute(RealCall.java:57)
        at Connection.getLongPollResponse(Connection.java:44)
        at LongPoll.getLongPollHistory(LongPoll.java:7)
        at LongPollHandler.run(LongPollHandler.java:92)
Caused by: java.net.SocketTimeoutException: Read timed out
        at java.net.SocketInputStream.socketRead0(Native Method)
        at java.net.SocketInputStream.socketRead(Unknown Source)
        at java.net.SocketInputStream.read(Unknown Source)
        at java.net.SocketInputStream.read(Unknown Source)
        at sun.security.ssl.InputRecord.readFully(Unknown Source)
        at sun.security.ssl.InputRecord.read(Unknown Source)
        at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
        at sun.security.ssl.SSLSocketImpl.readDataRecord(Unknown Source)
        at sun.security.ssl.AppInputStream.read(Unknown Source)
        at okio.Okio$2.read(Okio.java:138)
        at okio.AsyncTimeout$2.read(AsyncTimeout.java:236)
        ... 16 more
java.lang.NullPointerException
        at java.io.StringReader.<init>(Unknown Source)
        at org.json.JSONTokener.<init>(JSONTokener.java:85)
        at org.json.JSONObject.<init>(JSONObject.java:319)
        at LongPollHandler.run(LongPollHandler.java:92)

LongPollHandler.java:92

Источник: https://ru.stackoverflow.com/questions/641287/%D0%9D%D0%B0%D0%B3%D1%80%D1%83%D0%B7%D0%BA%D0%B0-%D0%BD%D0%B0-longpoll-%D1%81%D0%B5%D1%80%D0%B2%D0%B5%D1%80-vk-api

Share

Тебе может это понравится...