Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request connection error #2666

Open
yerzhant opened this issue Jun 28, 2024 · 3 comments
Open

Request connection error #2666

yerzhant opened this issue Jun 28, 2024 · 3 comments
Labels
needs-triage Issue still needs to be assigned, labeled and deduplicated type: bug Something is broken or not working as intended

Comments

@yerzhant
Copy link

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

@yerzhant yerzhant added needs-triage Issue still needs to be assigned, labeled and deduplicated type: bug Something is broken or not working as intended labels Jun 28, 2024
@yerzhant
Copy link
Author

One must not that this can be reset by switching on and off flight mode.

@yerzhant
Copy link
Author

yerzhant commented Jun 30, 2024

The issue also disappears if the other (advertising) party switches flight mode on. If the advertising party switches flight mode off the issue arises again.

@yerzhant
Copy link
Author

On trying to discover a second time one can see in logs these errors:

2024-06-30 19:56:52.776 15057-7489  NearbyMediums           com.google.android.gms.persistent    E  MEDIUM_ERROR [SYSTEM][WIFI_LAN][CONNECT][ESTABLISH_CONNECTION_FAILED][UNKNOWN], service-id=com.example.nbs
2024-06-30 19:56:52.797 15057-7489  NearbyMediums           com.google.android.gms.persistent    E  MEDIUM_ERROR [SYSTEM][WIFI_LAN][CONNECT][ESTABLISH_CONNECTION_FAILED][UNKNOWN], service-id=com.example.nbs
2024-06-30 19:56:52.807 15057-7489  NearbyMediums           com.google.android.gms.persistent    E  MEDIUM_ERROR [SYSTEM][WIFI_LAN][CONNECT][ESTABLISH_CONNECTION_FAILED][UNKNOWN], service-id=com.example.nbs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-triage Issue still needs to be assigned, labeled and deduplicated type: bug Something is broken or not working as intended
Projects
None yet
Development

No branches or pull requests

1 participant