Giter VIP home page Giter VIP logo

Comments (7)

edgarclerigo avatar edgarclerigo commented on May 19, 2024 1

@bourdakos1 forgot to tell that the startDiscovery is working as expected

from nearby.

bourdakos1 avatar bourdakos1 commented on May 19, 2024 1

Thanks for verifying! I need to look into how to properly handle this case

from nearby.

bourdakos1 avatar bourdakos1 commented on May 19, 2024 1

Awesome! So it is just a matter of retrying. I'll update this issue to reflect the need for adding internal retry logic for Wi-Fi LAN

from nearby.

edgarclerigo avatar edgarclerigo commented on May 19, 2024 1

Thanks for answering so fast! I will keep subscribed on this issue so we can update the lib on our end :)

from nearby.

bourdakos1 avatar bourdakos1 commented on May 19, 2024

It looks like it failed to start listening for incoming connections, but the system didn't return any an explicit errors. My best guess is that the listener transitioned to the nw_listener_state_waiting which isn't a fatal error, but will end in a fatal nearby error, since we don't attempt retries: https://developer.apple.com/documentation/network/nw_listener_state_t/nw_listener_state_waiting?language=objc

However, I don't have an iOS 14.8.1 device to verify. Do you mind trying to add some logs here:

to see what state the listener is in?

I can also push an update with more logs if thats easier, but that might take some time to get reviewed/submitted

from nearby.

edgarclerigo avatar edgarclerigo commented on May 19, 2024

It looks like your guessing is correct,
Screenshot 2023-08-10 at 20 57 25
Screenshot 2023-08-10 at 20 57 27

from nearby.

edgarclerigo avatar edgarclerigo commented on May 19, 2024

I made this workaround

private func startAdvertise(nearbyMessage: NearbyMessage, retryCount: Int) {
        print("[NearbyManager] Retrying startAdvertise: \(retryCount)")

        guard
            let nearbyMessageData = nearbyMessage.dataValue,
            retryCount > 0
        else {
            return
        }

        advertiser.startAdvertising(
            using: nearbyMessageData,
            completionHandler: { error in
                guard let error = error else {
                    print("[NearbyManager] Success on startAdvertising")
                    return
                }

                print("[NearbyManager] Failed to advertise: \(error.localizedDescription)")

                let timer = Timer.scheduledTimer(withTimeInterval: 1.0, repeats: false) { [weak self] timer in
                    self?.startAdvertise(nearbyMessage: nearbyMessage, retryCount: retryCount-1)
                }
                timer.fire()
            }
        )
    }

Eventually it will work:

[NearbyManager] Retrying startAdvertise: 10
[NearbyManager] Failed to advertise: The operation couldn’t be completed. (com.google.nearby.connections.error error 11.)
[NearbyManager] Retrying startAdvertise: 9
[NearbyManager] Failed to advertise: The operation couldn’t be completed. (com.google.nearby.connections.error error 11.)
[NearbyManager] Retrying startAdvertise: 8
[NearbyManager] Success on startAdvertising

from nearby.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.