odyshewroman / AndroidTVRemoteControl

MIT License
31 stars 9 forks source link

No message available on STREAM & Connection reset by peer #18

Closed RomainBouchaud closed 9 months ago

RomainBouchaud commented 9 months ago

Hello,

I've had some trouble with the connection with the TV. I try to disconnect from the device when apps goes in background, for it not to spam with ping/pong when in background. I modified the demo project to disconnect remoteManager and pairingManager in SceneDelegate sceneDidEnterBackground. And I call RemoteManager connect function in SceneDelegate sceneDidBecomeActive. Problem is that when I start app, everything is OK. I put app in background, disconnection is done. I go back to the app, it connects and works fine, vol +, vol - I put app in background, disconnection is done. I go back to the app, it seems to connect but commands don't work, I receive No message available on STREAM error. I try another command, I receive Connection reset by peer error.

Here are the actions done to capture the logs: Start the app Vol+ Vol- App to background Go to app Vol+ Vol- App to background Go to app Vol+ Vol-

Here are the logs:

Info: Remote: connecting 192.168.1.42:6466 Info: Remote: connection preparing Info: Remote: connected Debug: Remote: handle: [89, 10, 87, 8, 255, 4, 18, 82, 10, 13, 67, 104, 114, 111, 109, 101, 99, 97, 115, 116, 32, 72, 68, 18, 6, 71, 111, 111, 103, 108, 101, 24, 1, 34, 2, 49, 50, 42, 36, 99, 111, 109, 46, 103, 111, 111, 103, 108, 101, 46, 97, 110, 100, 114, 111, 105, 100, 46, 116, 118, 46, 114, 101, 109, 111, 116, 101, 46, 115, 101, 114, 118, 105, 99, 101, 50] Debug: Remote: Sending first configuration request Info: Remote: fisrt configuration message has been received: Google Chromecast HD com.google.android.tv.remote.service -1 12 Debug: Remote: Sending data: [50] Info: Remote: fisrt configuration has been sent Debug: Remote: Success sent Debug: Remote: Sending data: [10, 48, 8, 238, 4, 18, 43, 10, 6, 99, 108, 105, 101, 110, 116, 18, 6, 105, 80, 104, 111, 110, 101, 24, 1, 34, 3, 50, 51, 53, 42, 11, 101, 120, 97, 109, 112, 108, 101, 95, 97, 112, 112, 50, 5, 49, 46, 48, 46, 48] Debug: Remote: handle: [13, 53, 46, 50, 46, 52, 55, 51, 50, 53, 52, 49, 51, 51] Debug: Remote: it's not first configuration response Debug: Remote: Success sent Debug: Remote: handle: [13, 53, 46, 50, 46, 52, 55, 51, 50, 53, 52, 49, 51, 51, 2, 18, 0] Debug: Remote: first configuration response was received Debug: Remote: Sending second configuration request Debug: Remote: Sending data: [5] Info: Remote: second configuration has been sent Debug: Remote: Success sent Debug: Remote: Sending data: [18, 3, 8, 238, 4] Debug: Remote: Success sent Debug: Remote: handle: [5, 194, 2, 2, 8, 1] Debug: Remote: second configuration response POWER - OK Debug: Remote: handle: [24, 146, 3, 21, 8, 97] Debug: Remote: it's not second configuration response Debug: Remote: handle: [24, 146, 3, 21, 8, 97, 16, 9, 26, 13, 67, 104, 114, 111, 109, 101, 99, 97, 115, 116, 32, 72, 68, 32, 1] Debug: Remote: second configuration response POWER - OK Debug: Remote: second configuration response VOLUME LEVEL - OK Debug: Remote: handle: [43, 162, 1, 40, 10, 38, 98, 36, 99, 111, 109, 46, 103, 111, 111, 103, 108, 101, 46, 97, 110, 100, 114, 111, 105, 100, 46, 97, 112, 112, 115, 46, 116, 118, 46, 108, 97, 117, 110, 99, 104, 101, 114, 120] Debug: Remote: second configuration response CURRENT APP - OK Debug: Remote: second configuration response POWER - OK Debug: Remote: second configuration response VOLUME LEVEL - OK Info: Remote: paired, current running app: com.google.android.apps.tv.launcherx Debug: Remote: Sending data: [6] Debug: Remote: Success sent Debug: Remote: Sending data: [82, 4, 8, 24, 16, 3] Debug: Remote: Success sent Debug: Remote: Sending data: [6] Debug: Remote: Success sent Debug: Remote: Sending data: [82, 4, 8, 25, 16, 3] Debug: Remote: Success sent Info: Remote: disconnect Info: Pairing: disconnect Info: Remote: Empty or completion data received Info: Remote: connecting 192.168.1.42:6466 Info: Remote: connection preparing Info: Remote: connected Debug: Remote: handle: [89, 10, 87, 8, 255, 4, 18, 82, 10, 13, 67, 104, 114, 111, 109, 101, 99, 97, 115, 116, 32, 72, 68, 18, 6, 71, 111, 111, 103, 108, 101, 24, 1, 34, 2, 49, 50, 42, 36, 99, 111, 109, 46, 103, 111, 111, 103, 108, 101, 46, 97, 110, 100, 114, 111, 105, 100, 46, 116, 118, 46, 114, 101, 109, 111, 116, 101, 46, 115, 101, 114, 118, 105, 99, 101, 50, 13, 53, 46, 50, 46, 52, 55, 51, 50, 53, 52, 49, 51, 51] Debug: Remote: Sending first configuration request Info: Remote: fisrt configuration message has been received: Google Chromecast HD com.google.android.tv.remote.service 5.2.473254133 12 Debug: Remote: Sending data: [50] Info: Remote: fisrt configuration has been sent Debug: Remote: Success sent Debug: Remote: Sending data: [10, 48, 8, 238, 4, 18, 43, 10, 6, 99, 108, 105, 101, 110, 116, 18, 6, 105, 80, 104, 111, 110, 101, 24, 1, 34, 3, 50, 51, 53, 42, 11, 101, 120, 97, 109, 112, 108, 101, 95, 97, 112, 112, 50, 5, 49, 46, 48, 46, 48] Debug: Remote: Success sent Debug: Remote: handle: [2, 18, 0] Debug: Remote: first configuration response was received Debug: Remote: Sending second configuration request Debug: Remote: Sending data: [5] Info: Remote: second configuration has been sent Debug: Remote: Success sent Debug: Remote: Sending data: [18, 3, 8, 238, 4] Debug: Remote: Success sent Debug: Remote: handle: [5, 194, 2, 2, 8, 1] Debug: Remote: it's not second configuration response Debug: Remote: handle: [5, 194, 2, 2, 8, 1, 24, 146, 3, 21, 8, 97, 16, 9, 26, 13, 67, 104, 114, 111, 109, 101, 99, 97, 115, 116, 32, 72, 68, 32, 1] Debug: Remote: it's not second configuration response Debug: Remote: handle: [5, 194, 2, 2, 8, 1, 24, 146, 3, 21, 8, 97, 16, 9, 26, 13, 67, 104, 114, 111, 109, 101, 99, 97, 115, 116, 32, 72, 68, 32, 1, 43, 162, 1, 40, 10, 38, 98, 36, 99, 111, 109, 46, 103, 111, 111, 103, 108, 101, 46, 97, 110, 100, 114, 111, 105, 100, 46, 97, 112, 112, 115, 46, 116, 118, 46, 108, 97, 117, 110, 99, 104, 101, 114, 120] Debug: Remote: it's not second configuration response Debug: Remote: Sending data: [6] Debug: Remote: Success sent Debug: Remote: Sending data: [82, 4, 8, 24, 16, 3] Debug: Remote: Success sent Debug: Remote: Sending data: [6] Debug: Remote: Success sent Debug: Remote: Sending data: [82, 4, 8, 25, 16, 3] Debug: Remote: Success sent Info: Remote: disconnect Info: Pairing: disconnect Info: Remote: Empty or completion data received Info: Remote: connecting 192.168.1.42:6466 Info: Remote: connection preparing Info: Remote: connected Debug: Remote: handle: [5, 194, 2, 2, 8, 1, 24, 146, 3, 21, 8, 97, 16, 9, 26, 13, 67, 104, 114, 111, 109, 101, 99, 97, 115, 116, 32, 72, 68, 32, 1, 43, 162, 1, 40, 10, 38, 98, 36, 99, 111, 109, 46, 103, 111, 111, 103, 108, 101, 46, 97, 110, 100, 114, 111, 105, 100, 46, 97, 112, 112, 115, 46, 116, 118, 46, 108, 97, 117, 110, 99, 104, 101, 114, 120, 89, 10, 87, 8, 255, 4, 18, 82, 10, 13, 67, 104, 114, 111, 109, 101, 99, 97, 115, 116, 32, 72, 68, 18, 6, 71, 111, 111, 103, 108, 101, 24, 1, 34, 2, 49, 50, 42, 36, 99, 111, 109, 46, 103, 111, 111, 103, 108, 101, 46, 97, 110, 100, 114, 111, 105, 100, 46, 116, 118, 46, 114, 101, 109, 111, 116, 101, 46, 115, 101, 114, 118, 105, 99, 101, 50, 13, 53, 46, 50, 46, 52, 55, 51, 50, 53, 52, 49, 51, 51] Debug: Remote: it's not configuration message Debug: Remote: Sending data: [6] Debug: Remote: Success sent Debug: Remote: Sending data: [82, 4, 8, 24, 16, 3] Debug: Remote: Success sent Debug: Remote: handle: [5, 194, 2, 2, 8, 1, 24, 146, 3, 21, 8, 97, 16, 9, 26, 13, 67, 104, 114, 111, 109, 101, 99, 97, 115, 116, 32, 72, 68, 32, 1, 43, 162, 1, 40, 10, 38, 98, 36, 99, 111, 109, 46, 103, 111, 111, 103, 108, 101, 46, 97, 110, 100, 114, 111, 105, 100, 46, 97, 112, 112, 115, 46, 116, 118, 46, 108, 97, 117, 110, 99, 104, 101, 114, 120, 89, 10, 87, 8, 255, 4, 18, 82, 10, 13, 67, 104, 114, 111, 109, 101, 99, 97, 115, 116, 32, 72, 68, 18, 6, 71, 111, 111, 103, 108, 101, 24, 1, 34, 2, 49, 50, 42, 36, 99, 111, 109, 46, 103, 111, 111, 103, 108, 101, 46, 97, 110, 100, 114, 111, 105, 100, 46, 116, 118, 46, 114, 101, 109, 111, 116, 101, 46, 115, 101, 114, 118, 105, 99, 101, 50, 13, 53, 46, 50, 46, 52, 55, 51, 50, 53, 52, 49, 51, 51, 12, 26, 10, 8, 2, 18, 6, 82, 4, 8, 24, 16, 3] Debug: Remote: it's not configuration message Info: Remote: Empty or completion data received nw_flow_add_read_request [C3 192.168.1.42:6466 ready channel-flow (satisfied (Path is satisfied), viable, interface: en0[802.11], ipv4, dns, uses wifi)] already delivered final read, cannot accept read requests nw_read_request_report [C3] Receive failed with error "No message available on STREAM" Error: Remote: Connection Error: receive data error - The operation couldn’t be completed. (Network.NWError error 96 - No message available on STREAM) Debug: Remote: Sending data: [6] Debug: Remote: Success sent Debug: Remote: Sending data: [82, 4, 8, 25, 16, 3] Debug: Remote: Success sent tcp_input [C3:2] flags=[R] seq=222094375, ack=0, win=0 state=CLOSE_WAIT rcv_nxt=222094375, snd_una=1337405971 Info: Remote: disconnect Error: Remote: Connection Error: connection failed - The operation couldn’t be completed. (Network.NWError error 54 - Connection reset by peer)

Do you have an idea of what is going wrong? Thank you.

odyshewroman commented 9 months ago

Hi, in RemoteManager disconnect function add line secondConfigurationResponse = SecondConfigurationResponse() and try, pls notify me about results.

RomainBouchaud commented 9 months ago

Hi, thanks for your quick reply. Looks like it fixes the issue. I will try a bit more and let you know.

RomainBouchaud commented 9 months ago

I confirm that this fixes the issue. Thank you!