Skip to content

Request connection error #2666

Description

@yerzhant

Project

Nearby Connections

Language

Other

OS Platform

Linux

What happened?

With this code:

    private val endpointDiscoveryCallback = object : EndpointDiscoveryCallback() {
        override fun onEndpointFound(
            endpoint: String,
            discoveredEndpointInfo: DiscoveredEndpointInfo
        ) {
            remoteEndpoint = endpoint
            client.requestConnection(
                "Receiver",
                endpoint,
                discovererConnectionCallback
            )
                .addOnSuccessListener { client.stopDiscovery() }
                .addOnFailureListener { Log.e(logTag, "Failed to request a connection", it) }
        }

        override fun onEndpointLost(endpoint: String) {
            Log.e(logTag, "Endpoint $endpoint lost")
        }
    }

    override fun discover() {
        val options = DiscoveryOptions.Builder().setStrategy(P2P_POINT_TO_POINT).build()
        client.startDiscovery(serviceId, endpointDiscoveryCallback, options)
            .addOnFailureListener { Log.e(logTag, "Discovery failed", it) }
    }

First run is fine but the second and further ones return this error:

E/NearByService(31054): Failed to request a connection
E/NearByService(31054): com.google.android.gms.common.api.ApiException: 13: ERROR
E/NearByService(31054): 	at com.google.android.gms.internal.nearby.zzdo.setFailedResult(com.google.android.gms:play-services-nearby@@19.2.0:1)
E/NearByService(31054): 	at com.google.android.gms.internal.nearby.zzce.zzb(com.google.android.gms:play-services-nearby@@19.2.0:4)
E/NearByService(31054): 	at com.google.android.gms.internal.nearby.zzfr.zza(com.google.android.gms:play-services-nearby@@19.2.0:3)
E/NearByService(31054): 	at com.google.android.gms.internal.nearby.zzb.onTransact(com.google.android.gms:play-services-nearby@@19.2.0:3)
E/NearByService(31054): 	at android.os.Binder.execTransactInternal(Binder.java:1380)
E/NearByService(31054): 	at android.os.Binder.execTransact(Binder.java:1311)

What did you expect to happen?

Request connection should succeed.

How can we reproduce it (as minimally and precisely as possible)?

Try to discover like this:

    private val endpointDiscoveryCallback = object : EndpointDiscoveryCallback() {
        override fun onEndpointFound(
            endpoint: String,
            discoveredEndpointInfo: DiscoveredEndpointInfo
        ) {
            remoteEndpoint = endpoint
            client.requestConnection(
                "Receiver",
                endpoint,
                discovererConnectionCallback
            )
                .addOnSuccessListener { client.stopDiscovery() }
                .addOnFailureListener { Log.e(logTag, "Failed to request a connection", it) }
        }

        override fun onEndpointLost(endpoint: String) {
            Log.e(logTag, "Endpoint $endpoint lost")
        }
    }

    override fun discover() {
        val options = DiscoveryOptions.Builder().setStrategy(P2P_POINT_TO_POINT).build()
        client.startDiscovery(serviceId, endpointDiscoveryCallback, options)
            .addOnFailureListener { Log.e(logTag, "Discovery failed", it) }
    }

How often does this bug happen?

Often

Standalone code to reproduce the issue

No response

Relevant log output

No response

Anything else we need to know?

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triageIssue still needs to be assigned, labeled and deduplicatedtype: bugSomething is broken or not working as intended

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions