-
Notifications
You must be signed in to change notification settings - Fork 153
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
iOS connection error when advertising #1702
Comments
Hey! I am also having problems related to this. But, in my case, it also happens when both devices are configured to follow a "Point to Point" strategy. It seems that it does not depend on the connection strategy selected. Following the same scenario that @IgVelasco described above, I ALWAYS receive the "libprotobuf ERROR" on the advertiser's side. I can also see this, just behind the relevant log described above:
And, in terms of the UI from the example, the advertiser shows the buttons to "Send bytes", but the discoverer device shows the "Accept/Reject" buttons in a disabled state. |
@IgVelasco and @DonatoJP thanks for reporting! I am able to reproduce the issue and I'm looking into a fix |
Do you mind trying #1703 and see if that resolves the issue? |
Objective-C objects cannot be captured by reference in C++ lambdas and must always be captured by value. This also takes a copy of the data returned from the Wi-Fi LAN reader, to prevent potential intermittent empty packet issues. Fixes: #1702 PiperOrigin-RevId: 533914865
Yes looks like that fixes the issue thanks! |
@bourdakos1 thanks a lot! This solves the issue |
Objective-C objects cannot be captured by reference in C++ lambdas and must always be captured by value. This also takes a copy of the data returned from the Wi-Fi LAN reader, to prevent potential intermittent empty packet issues. Fixes: #1702 PiperOrigin-RevId: 533914865
Objective-C objects cannot be captured by reference in C++ lambdas and must always be captured by value. This also takes a copy of the data returned from the Wi-Fi LAN reader, to prevent potential intermittent empty packet issues. Fixes: #1702 PiperOrigin-RevId: 533925980
Hi @bourdakos1 , could it be that this is failing again? Maybe there was a change in the library
Pretty much the same error |
Hmm I don’t see any recent changes that would break things, but I’ll take a closer look tomorrow and try to reproduce |
Thanks, let me know if I can be of any help! |
@bourdakos1 I've tried the example and is working correctly but im having a problem with my implementation were this error raises no matter what, is a simple implementation where I'm setting the connection handler and verification handler on true instantly Do you have any idea what could be the issue? I'll close this issue since in the IOS Example is working correctly |
Hmm I’m not sure. Are you able to share any of the code? |
Hey @bourdakos1, I am having the same issue. I am trying to connect one iOS device (iPhone 13 Pro iOS 17.4) as an advertiser with another iOS device (iPhone 15 Pro iOS 17.3.1) as a discoverer. The problem starts when I send the connection request from the discoverer device (using In the advertiser device I can see this:
The last 6 lines are repeated every 5 seconds. On the other hand, in my discoverer device I can see this:
Again, every 5-6 seconds. It seems they are trying to exchange some data but the library is having problems to decode those packets. Is this example more accurate? Thanks in advance! |
@bourdakos1 This is the code that im using, I also tried to use the code for the example enforcing the connection always to be accepted and failed. I also tried using the hash of the following commit and this did work. Im not sure if its something with a change in the library or something related to the direct accept
|
The advertiser and connection manager code looks fine to me, do you have a code snippet for the discoverer side? |
The code is part of a flutter plugin we are working on, I started the code on the swift side since the android part is quite done. So Im doing the advertisement only for now, and discovering using an android device. Maybe I could share the discovery code later :) |
The code is pretty much the same since I instantiate a new Connector class which contains the verificationHandler set to true class NCDiscoverer: Connector, DiscovererDelegate {
var discoverer: Discoverer?
init(serviceId: String,
strategy: String,
context: UIApplication,
callbacks: DiscovererCallbacks,
userName: String = GeneralConstants.DEFAULT_USERNAME) {
self.discoverer = nil
super.init(serviceId: serviceId,
strategy: strategy,
context: context,
callbacks: callbacks,
userName: userName)
discoverer = Discoverer(connectionManager: connectionManager)
discoverer!.delegate = self
}
func discoverer(
_ discoverer: Discoverer, didFind endpointID: EndpointID, with context: Data) {
// An endpoint was found.
var endpointName = String(decoding: context, as: UTF8.self)
(callbacks as! any DiscovererCallbacks as DiscovererCallbacks)
.onEndpointFound(
endpointId: endpointID,
endpointName: endpointName
)
}
func discoverer(_ discoverer: Discoverer, didLose endpointID: EndpointID) {
// A previously discovered endpoint has gone away.
(callbacks as! any DiscovererCallbacks as DiscovererCallbacks).onEndpointLost(endpointId: endpointID)
}
func connect(endpointId: String) {
let completionHandler: (Error?) -> Void = {(error) in
print(error ?? "Requested connection to \(endpointId)")
};
discoverer?.requestConnection(to: endpointId, using: userName)
}
func startDiscovering() {
let completionHandler: (Error?) -> Void = {(error) in
print(error ?? "Starting to discover devices in iOS")
};
discoverer!.startDiscovery(completionHandler: completionHandler);
}
} |
Project
Nearby Connections
Language
Swift
OS Platform
Apple
What happened?
When using an iOS device as an advertiser, the connection fails after being accepted (via code automatically or using the iOS Example provided in the repository) due to a parsing error in the secure message.
What did you expect to happen?
I expected the connection to be accepted. When using the iOS device as a discoverer, I do not encounter any problems when connecting to an Android device that is advertising.
How can we reproduce it (as minimally and precisely as possible)?
I have run multiple scenarios, all resulting in the same output:
Devices:
iPhone running iOS 16.5
iPad running iOS 16.5
Steps:
(using cluster/star strategy)
I have also tried other scenarios using the iOS device as an advertiser and tested the iOS Example provided in the repository. In all cases, the same error occurred. Occasionally, the connection was approved, but I was unable to determine the reason why.
How often does this bug happen?
Often
Standalone code to reproduce the issue
The error was able to be produce with the iOS example, let me know if you are not being able to reproduce it.
Relevant log output
Anything else we need to know?
The text was updated successfully, but these errors were encountered: