watson-developer-cloud / java-sdk

:1st_place_medal: Java SDK to use the IBM Watson services.
http://watson-developer-cloud.github.io/java-sdk/
Apache License 2.0
590 stars 533 forks source link

[Speech-to-text] Websocket remains open after inputstream is closed #689

Closed ghost closed 7 years ago

ghost commented 7 years ago

Hi all,

When using the Speech-To-Text service the websocket keeps streaming even after closing the inputstream. Eventually it times out after 30 seconds of inactivity and throwing this following exception:

SEVERE: Session timed out, no data received in the last 30 seconds.
java.lang.RuntimeException: Session timed out, no data received in the last 30 seconds.
    at com.ibm.watson.developer_cloud.speech_to_text.v1.websocket.WebSocketManager$SpeechToTextWebSocketListener.onMessage(WebSocketManager.java:140)
    at okhttp3.internal.ws.RealWebSocket.onReadMessage(RealWebSocket.java:307)
    at okhttp3.internal.ws.WebSocketReader.readMessageFrame(WebSocketReader.java:222)
    at okhttp3.internal.ws.WebSocketReader.processNextFrame(WebSocketReader.java:101)
    at okhttp3.internal.ws.RealWebSocket.loopReader(RealWebSocket.java:262)
    at okhttp3.internal.ws.RealWebSocket$2.onResponse(RealWebSocket.java:201)
    at okhttp3.RealCall$AsyncCall.execute(RealCall.java:141)
    at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

My question is: Can I avoid this by manually closing the websocket? If so, how?

Using the latest version:

<dependency>
      <groupId>com.ibm.watson.developer_cloud</groupId>
      <artifactId>java-sdk</artifactId>
      <version>3.8.0</version>
  </dependency>
germanattanasio commented 7 years ago

I'm working on this @JonLNielsen.

ghost commented 7 years ago

Thanks @germanattanasio - Looking forward to see your solution.

germanattanasio commented 7 years ago

@JonLNielsen Once I merge #691 it will be in sonatype snapshots. Check the readme for instructions on how to use the snapshot repository. It will be great if you can validate that this issue was fixed