1

I have 2 devices:

  • one is advertising (server app running on android 11)
  • one is discovering (client app running on android 4.4.2).

Both have the latest version of the Google Play Services.

On connection, the client app is sending some bytes to the server app; depending on those, it will send back bytes or a file. It works on all client devices I have except the Galaxy Tab 3 and I have no idea why. Sending bytes works, but not sending files (file is approx. 25Mo! i've tried 5Kb, same result : Payload Failure). On failing, client disconnects from server and then reconnects to it, only to fail again. After some tries, a pop-up often appears saying Play Services have stopped.

Does anyone have an idea why this is happening on this specific device?

I have some logs from my server app :

? I/NearbyConnections: EndpointManager failed the next Read read/write for endpoint ZPYv over its ENCRYPTED_BLUETOOTH EndpointChannel. [CONTEXT service_id=54 ]
    java.io.IOException: bt socket closed, read return: -1
        at android.bluetooth.BluetoothSocket.read(BluetoothSocket.java:550)
        at android.bluetooth.BluetoothInputStream.read(BluetoothInputStream.java:88)
        at java.io.BufferedInputStream.fill(BufferedInputStream.java:248)
        at java.io.BufferedInputStream.read1(BufferedInputStream.java:288)
        at java.io.BufferedInputStream.read(BufferedInputStream.java:347)
        at java.io.DataInputStream.readFully(DataInputStream.java:198)
        at java.io.DataInputStream.readInt(DataInputStream.java:389)
        at agmx.e(:com.google.android.gms@203315046@20.33.15 (150400-330018294):1)
        at agoz.a(:com.google.android.gms@203315046@20.33.15 (150400-330018294):1)
        at agow.run(:com.google.android.gms@203315046@20.33.15 (150400-330018294):4)
        at agiy.run(Unknown Source:0)
        at qzr.b(:com.google.android.gms@203315046@20.33.15 (150400-330018294):12)
        at qzr.run(:com.google.android.gms@203315046@20.33.15 (150400-330018294):7)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at rfq.run(:com.google.android.gms@203315046@20.33.15 (150400-330018294):0)
        at java.lang.Thread.run(Thread.java:923)
? I/NearbyConnections: EndpointManager quit overall Read loop for endpoint ZPYv because the currently registered ENCRYPTED_BLUETOOTH EndpointChannel is in a failed state. [CONTEXT service_id=54 ]
? I/NearbyConnections: Failed to close write stream of ENCRYPTED_BLUETOOTH EndpointChannel BluetoothClassicSocket:C4:62:EA:38:FD:08: socket closed [CONTEXT service_id=54 ]
? I/NearbyConnections: EndpointChannelManager unregistered endpoint ZPYv [CONTEXT service_id=54 ]
? I/NearbyConnections: ClientProxy(80700159) ignoring onConnectionResult(ZPYv, ERROR) because this client has no pending connections to the endpoint [CONTEXT service_id=54 ]
? I/NearbyMediums: Closed Wifi Direct channel. [CONTEXT service_id=54 ]
? E/NearbyMediums: There's no Direct hotspot to stop when the Wi-Fi Direct channel disconnected. [CONTEXT service_id=54 ]

And the exception line from the bug report dialog on my client app (dialog doesn't show up every time so I don't know if this is the reason behind the Nearby's failure) :

java.lang.IllegalArgumentException: Requested flags 0x43, but only 0x3 are allowed
  • just found out i had some logs, added them since they're not helping :) – Victorien Fischer Sep 16 '20 at 15:53
  • "Play Services have stopped" means there's a crash on our (Nearby's) end. Can you filter for errors (adb logcat *:e) and attach that? A crash usually has the log tag "AndroidRuntime". – Xlythe Sep 16 '20 at 16:49
  • hello @Xlythe! Sadly my usb cable just died and i won't be able to get one until next week. But I still have some data from the bug report dialog. Exception class is IllegalArgumentException from android.os.Parcel class. Source method seems to be readException (line 1469). Stack trace says : `Requested flags 0x43, but only 0x3 are allowed` – Victorien Fischer Sep 17 '20 at 12:26
  • seems like its a known bug on kitkat (api 19). Unfortunately, the app i'm dealing with is aiming for at least api 16. Btw, the "Play Services have stopped" dialog doesn't show every time. Is it an expected behavior ? – Victorien Fischer Sep 17 '20 at 12:34
  • I've submitted a fix on our side. It'll take ~1 month to roll out. The reason "Play Services have stopped" doesn't show every time is because we have some internal logic that tries to catch crashes and recover, but there's a counter and it won't recover indefinitely. If you look for "DeviceDoctor", you may see logs from it. – Xlythe Sep 17 '20 at 17:09
  • @Xlythe I'm having similar issue, please help https://stackoverflow.com/questions/65487748/nearby-connection-keeps-disconnected-when-sending-files – Nguyen Van Hanh Dec 30 '20 at 08:11

1 Answers1

0

This is a bug in Nearby Connection's code! It's an instance of IllegalArgumentException in grantUriPermission on API level 19

I've just submitted a fix, but it'll take roughly a month until it's rolled out to devices.

Disclaimer: I work on Nearby

Xlythe
  • 1,958
  • 1
  • 8
  • 12
  • can you answer to my quest please? https://stackoverflow.com/questions/72487456/problem-sending-file-using-google-nearby-bandwidth-upgrade-negotiation-upgrade-p – Daryn Jun 03 '22 at 09:22