question

Jj__17 avatar image
Jj__17 asked

TimeoutException while trying to connect to Fire Stick

I am developing android app, with feature of casting to Fire Stick. While connecting to it I often get TimeoutException:

FlingMediaRouteProvider ,
message: Error attempting to add status listener , throwable message:
throwable class: java.util.concurrent.TimeoutException   
java.util.concurrent.TimeoutException       
at java.util.concurrent.FutureTask.get(FutureTask.java:206)       
atFlingMediaRouteProvider$FlingRouteController
.setItemUpdateReceiver(FlingMediaRouteProvider.java:521)

It is line below:

this.mDevice.addStatusListener(this.mListener).get(5000L, TimeUnit.MILLISECONDS);

I was debugging that problem without success for long time. One thing I have noticed, is that this problem repeats. When I get it once, I get it every time when I try to connect again.
It disappears only in 2 cases:
- after some time passes,
- when I reset Fire Stick (unplug it from and plug it into power supply again)

Sometimes I also get similar TimeoutException, but while removing status listener.

Does someone have any experience with similar issues? How can I fix it?

fire tvamazon fling
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

k4zik avatar image
k4zik answered

I also have issues with connecting to FireStick. Especially when the device goes to sleep, then I can't connect to it again, because I have:

Error attempting to add status listener

Also, I try to run using fling SDK sample I have issues when the firestick is sleeping then I cannot connect to it. Attached logs from the sample app.

2021-04-27 15:48:19.436 8469-8895/com.amazon.whisperplay.example.flingsample I/com.amazon.whisperplay.example.flingsample.FlingActivity: [8895]ConnectionUpdateTask:addStatusListener:target=Jakub's Fire TV Stick (6ED942673DE1BA5FECC8E80BC5BB6A72)
2021-04-27 15:48:19.438 8469-8895/com.amazon.whisperplay.example.flingsample I/WPControllerAdapter: registerHandlerForDevice - getting from processor
2021-04-27 15:48:19.443 8469-8895/com.amazon.whisperplay.example.flingsample D/PlayerDeviceImpl: addStatusListener - cb:DeviceCallback(device:Device(friendlyName:, uuid:C96E9CCB23EE167DE0268C2A6F9B3CFA, deviceType:0, exInfo:ExtendedInfo(deviceClassMajor:Computer, deviceClassMinor:Android, manufacturer:Xiaomi, model:Mi A2, OSMajor:10, OSMinor:V11.0.23.0.QDIMIXM, capabilities:Dictionary(version:1, entries:{FlingSDKVersion=1.4.0})), routes:{inet=Route(hardwareAddr:0e:4b:dc:7d:56:8b, ipv4:10.11.17.20, uri:uri:urn:inet-endpoint:ssid:<unknown ssid>:mac:0e\:4b\:dc\:7d\:56\:8b:ipv4:10.11.17.20:unsec:37355:sec:0, unsecurePort:37355)}), callbackService:Description(sid:wlink_cb_1_com.amazon.whisperplay.example.flingsample, friendlyName:null, accessLevel:0, security:0, flags:0, version:0), commChannelId:memory)
2021-04-27 15:48:19.447 8469-8713/com.amazon.whisperplay.example.flingsample D/WhisperLink: Connection - Connection Attempt #:0: Excluded transports :[]
2021-04-27 15:48:19.448 8469-8713/com.amazon.whisperplay.example.flingsample D/WhisperLink: Connection - doConnectOnce, device=[device=null], service=Description(sid:amzn.reg, friendlyName:null, accessLevel:3, security:0, flags:0, version:1), protocol=null, channel=null; excluded=[]
2021-04-27 15:48:19.451 8469-8713/com.amazon.whisperplay.example.flingsample D/WhisperLink: TTransportManager - Get transport for local device amzn.reg
2021-04-27 15:48:19.452 8469-8713/com.amazon.whisperplay.example.flingsample D/WhisperLink: Connection - Returning a cache transport for amzn.reg
2021-04-27 15:48:19.453 8469-8713/com.amazon.whisperplay.example.flingsample D/WhisperLink: Connection - calling Connection.close for device() [device=null]
2021-04-27 15:48:19.454 8469-8713/com.amazon.whisperplay.example.flingsample D/PlayerDeviceImpl: callService.run() - connection=com.amazon.whisperlink.util.Connection@f9d6dc
2021-04-27 15:48:19.454 8469-8713/com.amazon.whisperplay.example.flingsample D/WhisperLink: Connection - Connection Attempt #:0: Excluded transports :[]
2021-04-27 15:48:19.455 8469-8713/com.amazon.whisperplay.example.flingsample D/WhisperLink: Connection - doConnectOnce, device=[device: local=false, uuid=6ED942673DE1BA5FECC8E80BC5BB6A72, routes={inet=Route(ipv4:10.11.17.36, unsecurePort:48383, securePort:56324)}], service=Description(sid:amzn.thin.pl, friendlyName:null, accessLevel:0, security:0, flags:0, version:0), protocol=null, channel=null; excluded=[]
2021-04-27 15:48:19.456 8469-8510/com.amazon.whisperplay.example.flingsample D/OpenGLRenderer: endAllActiveAnimators on 0x7a19cbff00 (AlertController$RecycleListView) with handle 0x7a19c23600
2021-04-27 15:48:19.456 8469-8713/com.amazon.whisperplay.example.flingsample D/WhisperLink: Connection - Connection Attempt #:0: Excluded transports :[]
2021-04-27 15:48:19.457 8469-8713/com.amazon.whisperplay.example.flingsample D/WhisperLink: Connection - doConnectOnce, device=[device=null], service=Description(sid:amzn.reg, friendlyName:null, accessLevel:3, security:0, flags:0, version:1), protocol=null, channel=null; excluded=[]
2021-04-27 15:48:19.458 8469-8713/com.amazon.whisperplay.example.flingsample D/WhisperLink: TTransportManager - Get transport for local device amzn.reg
2021-04-27 15:48:19.458 8469-8713/com.amazon.whisperplay.example.flingsample D/WhisperLink: Connection - Returning a cache transport for amzn.reg
2021-04-27 15:48:19.461 8469-8713/com.amazon.whisperplay.example.flingsample D/WhisperLink: Connection - calling Connection.close for device() [device=null]
2021-04-27 15:48:19.462 8469-8713/com.amazon.whisperplay.example.flingsample D/WhisperLink: TTransportManager - Get transport for remote device amzn.thin.pl; channel:null
2021-04-27 15:48:19.463 8469-8713/com.amazon.whisperplay.example.flingsample D/WhisperLink: TTransportManager - Getting external transport for channel:inet: Channel connected? :true: ext channel :com.amazon.whisperlink.port.android.transport.TExternalSocketFactory@3eac1eb
2021-04-27 15:48:19.466 8469-8713/com.amazon.whisperplay.example.flingsample D/WhisperLink: TWhisperLinkTransport - Created TWhisperLinkTransport.  Token?false
2021-04-27 15:48:19.595 8469-8713/com.amazon.whisperplay.example.flingsample I/WhisperLink: TWhisperLinkTransport - Initiating connection to Service: amzn.thin.pl Connection Id: 5367 Channel: inet on Device: 6ED942673DE1BA5FECC8E80BC5BB6A72
2021-04-27 15:48:19.598 8469-8713/com.amazon.whisperplay.example.flingsample D/WhisperLink: TWhisperLinkTransport - headers written
2021-04-27 15:48:49.697 8469-8713/com.amazon.whisperplay.example.flingsample D/WhisperLink: TWhisperLinkTransport - First read of Client. Resp=200, remote?true
2021-04-27 15:48:49.699 8469-8713/com.amazon.whisperplay.example.flingsample D/PlayerDeviceImpl: callService.run() - client=com.amazon.whisperlink.service.fling.media.SimplePlayer$Client@adea16b
2021-04-27 15:48:49.699 8469-8713/com.amazon.whisperplay.example.flingsample D/PlayerDeviceImpl: addStatusListener - connected, calling clientcom.amazon.whisperlink.service.fling.media.SimplePlayer$Client@adea16b
2021-04-27 15:48:49.707 8469-8713/com.amazon.whisperplay.example.flingsample E/PlayerDeviceImpl: Exception: 
    org.apache.thrift.transport.TTransportException: Cannot read. Remote side has closed. Tried to read 4 bytes, but only got 0 bytes. (This is often indicative of an internal error on the server side. Please check your server logs.)
        at org.apache.thrift.transport.TTransport.readAll(TTransport.java:105)
        at com.amazon.whisperlink.transport.TWhisperLinkTransport.readAll(TWhisperLinkTransport.java:1638)
        at org.apache.thrift.protocol.TBinaryProtocol.readAll(TBinaryProtocol.java:402)
        at org.apache.thrift.protocol.TBinaryProtocol.readI32(TBinaryProtocol.java:355)
        at org.apache.thrift.protocol.TBinaryProtocol.readMessageBegin(TBinaryProtocol.java:248)
        at com.amazon.whisperlink.service.fling.media.SimplePlayer$Client.addStatusCallback(SimplePlayer.java:658)
        at com.amazon.whisperplay.fling.media.controller.impl.PlayerDeviceImpl$15.connected(PlayerDeviceImpl.java:330)
        at com.amazon.whisperplay.fling.media.controller.impl.PlayerDeviceImpl$15.connected(PlayerDeviceImpl.java:327)
        at com.amazon.whisperplay.fling.media.controller.impl.PlayerDeviceImpl$23.call(PlayerDeviceImpl.java:459)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:919)
2021-04-27 15:48:49.709 8469-8713/com.amazon.whisperplay.example.flingsample D/WhisperLink: Connection - calling Connection.close for device() [device: local=false, uuid=6ED942673DE1BA5FECC8E80BC5BB6A72, routes={inet=Route(ipv4:10.11.17.36, unsecurePort:48383, securePort:56324)}]
2021-04-27 15:48:49.716 8469-8713/com.amazon.whisperplay.example.flingsample I/WhisperLink: TWhisperLinkTransport - Closing connection for Service: amzn.thin.pl on Device 6ED942673DE1BA5FECC8E80BC5BB6A72 isClient: true Connection Id: 5367 Channel: inet
2021-04-27 15:48:49.717 8469-8895/com.amazon.whisperplay.example.flingsample E/com.amazon.whisperplay.example.flingsample.FlingActivity: [8895]ExecutionException msg=java.util.concurrent.ExecutionException: java.io.IOException: Cannot add StatusListener
2021-04-27 15:48:49.717 8469-8469/com.amazon.whisperplay.example.flingsample I/com.amazon.whisperplay.example.flingsample.FlingActivity: [main]ConnectionUpdateTask:onPostExecute: error handle
2021-04-27 15:48:49.717 8469-8469/com.amazon.whisperplay.example.flingsample E/com.amazon.whisperplay.example.flingsample.FlingActivity: errorMessagePopup: Showing the error message.
2021-04-27 15:48:49.794 8469-8469/com.amazon.whisperplay.example.flingsample I/com.amazon.whisperplay.example.flingsample.FlingActivity: resetDuration
2021-04-27 15:48:49.795 8469-8469/com.amazon.whisperplay.example.flingsample I/com.amazon.whisperplay.example.flingsample.FlingActivity: setStatusAndTitleVisibility:disable
2021-04-27 15:48:49.796 8469-8469/com.amazon.whisperplay.example.flingsample I/com.amazon.whisperplay.example.flingsample.FlingActivity: setPlaybackControllWorking:disable
2021-04-27 15:48:49.796 8469-8469/com.amazon.whisperplay.example.flingsample I/com.amazon.whisperplay.example.flingsample.FlingActivity: setProgressVisibility:disable
2021-04-27 15:48:49.800 8469-8469/com.amazon.whisperplay.example.flingsample I/com.amazon.whisperplay.example.flingsample.FlingActivity: setPlaybackControllWorking:disable
2021-04-27 15:48:49.800 8469-8469/com.amazon.whisperplay.example.flingsample I/com.amazon.whisperplay.example.flingsample.FlingActivity: setPickerIconVisibility: enable
2021-04-27 15:50:40.200 8469-8510/com.amazon.whisperplay.example.flingsample D/OpenGLRenderer: endAllActiveAnimators on 0x7a19cb4c00 (RippleDrawable) with handle 0x7a19c234a0

I need to restart the firestick to start working again for some time (wake up firestick not solving the issue). It's not a good user experience, which affects our app reviews. How to fix that?

10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Levon@Amazon avatar image
Levon@Amazon answered
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.