vksdk / vk-sdk-kotlin

Unofficial VK SDK, written in Kotlin: make bots, use the API
https://vksdk.github.io/vk-sdk-kotlin
MIT License
70 stars 16 forks source link

Application hangs on java.net.SocketInputStream.socketRead0 #9

Closed ishche closed 6 years ago

ishche commented 6 years ago

Hello! I tried to use your SDK on Ubuntu 16.04. Sometimes they stop receiving messages. I tried with Java 8 and Java 9:

openjdk version "1.8.0_171"
OpenJDK Runtime Environment (build 1.8.0_171-8u171-b11-0ubuntu0.16.04.1-b11)
OpenJDK 64-Bit Server VM (build 25.171-b11, mixed mode)
openjdk version "9-internal"
OpenJDK Runtime Environment (build 9-internal+0-2016-04-14-195246.buildd.src)
OpenJDK 64-Bit Server VM (build 9-internal+0-2016-04-14-195246.buildd.src, mixed mode)

jstack prints this stacktrace:

"threadLongpollListener" #39 prio=5 os_prio=0 tid=0x00007f76ac6a2000 nid=0x5df3 runnable [0x00007f76753ae000]
java.lang.Thread.State: RUNNABLE
        at java.net.SocketInputStream.socketRead0(java.base@9-internal/Native Method)
        at java.net.SocketInputStream.socketRead(java.base@9-internal/SocketInputStream.java:116)
        at java.net.SocketInputStream.read(java.base@9-internal/SocketInputStream.java:170)
        at java.net.SocketInputStream.read(java.base@9-internal/SocketInputStream.java:141)
        at sun.security.ssl.SSLSocketInputRecord.read(java.base@9-internal/SSLSocketInputRecord.java:425)
        at sun.security.ssl.SSLSocketInputRecord.bytesInCompletePacket(java.base@9-internal/SSLSocketInputRecord.java:65)
        at sun.security.ssl.SSLSocketImpl.bytesInCompletePacket(java.base@9-internal/SSLSocketImpl.java:900)
        - locked <0x00000000e3100560> (a java.lang.Object)
        at sun.security.ssl.AppInputStream.read(java.base@9-internal/AppInputStream.java:144)
        - locked <0x00000000e3102580> (a sun.security.ssl.AppInputStream)
        at java.io.BufferedInputStream.fill(java.base@9-internal/BufferedInputStream.java:246)
        at java.io.BufferedInputStream.read1(java.base@9-internal/BufferedInputStream.java:286)
        at java.io.BufferedInputStream.read(java.base@9-internal/BufferedInputStream.java:345)
        - locked <0x00000000e378a078> (a java.io.BufferedInputStream)
        at sun.net.www.http.HttpClient.parseHTTPHeader(java.base@9-internal/HttpClient.java:704)
        at sun.net.www.http.HttpClient.parseHTTP(java.base@9-internal/HttpClient.java:647)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(java.base@9-internal/HttpURLConnection.java:1534)
        - locked <0x00000000e37888b8> (a sun.net.www.protocol.https.DelegateHttpsURLConnection)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(java.base@9-internal/HttpURLConnection.java:1439)
        - locked <0x00000000e37888b8> (a sun.net.www.protocol.https.DelegateHttpsURLConnection)
        at java.net.HttpURLConnection.getResponseCode(java.base@9-internal/HttpURLConnection.java:480)
        at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(java.base@9-internal/HttpsURLConnectionImpl.java:319)
        at com.petersamokhin.bots.sdk.utils.web.Connection.getRequestResponse(Connection.java:38)
        at com.petersamokhin.bots.sdk.longpoll.LongPoll.startListening(LongPoll.java:228)
        at com.petersamokhin.bots.sdk.longpoll.LongPoll$$Lambda$18/707161353.run(Unknown Source)
        at java.lang.Thread.run(java.base@9-internal/Thread.java:804)
petersamokhin commented 6 years ago

Hello!

Your stacktrace not so readable. But you can see that it isn't library's issue:

at ...next
at java.net.HttpURLConnection.getResponseCode(java.base@9-internal/HttpURLConnection.java:480)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(java.base@9-internal/HttpsURLConnectionImpl.java:319)
at com.petersamokhin.bots.sdk.utils.web.Connection.getRequestResponse(Connection.java:38)
at ...previous

These lines say that exception is thrown when library tried to get response code. There are no dependencies for network jobs and only pure HttpUrlConnection used in this library.


I think it VK's issues and you need to manually handle such possible issues. From personal experience I can say that requests to VK's longpoll servers are responding with 504, 502 etc. error codes very often and you simply need to repeat the request.

Sorry, but library has no maintenance for a long time and now I can't help you. But you can make pull request if you want and make any improvements that you want.

petersamokhin commented 6 years ago

Closed due to inactivity.