Comments (15)
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:
[ERROR] DecodeMessageFromPeer: Failed to verify message.
2023-05-21 19:10:40.851 iOS Example[927/0x16b9cf000] [lvl=2] base_endpoint_channel.cc:158() Read: Read unencrypted KEEP_ALIVE on encrypted channel.
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.
from nearby.
@IgVelasco and @DonatoJP thanks for reporting! I am able to reproduce the issue and I'm looking into a fix
from nearby.
Do you mind trying #1703 and see if that resolves the issue?
from nearby.
Yes looks like that fixes the issue thanks!
from nearby.
@bourdakos1 thanks a lot! This solves the issue
from nearby.
@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
class NCAdvertiser: Connector, AdvertiserDelegate {
func advertiser(_ advertiser: Advertiser, didReceiveConnectionRequestFrom endpointID: EndpointID, with context: Data, connectionRequestHandler: @escaping (Bool) -> Void) {
connectionRequestHandler(true)
// TODO
}
var advertiser: Advertiser?
init(serviceId: String,
strategy: String,
context: UIApplication,
callbacks: AdvertiserCallbacks,
userName: String = GeneralConstants.DEFAULT_USERNAME,
manualAcceptConnections: Bool = false) {
self.advertiser = nil
super.init(serviceId: serviceId,
strategy: strategy,
context: context,
callbacks: callbacks,
userName: userName,
manualAcceptConnections: manualAcceptConnections)
advertiser = Advertiser(connectionManager: connectionManager)
advertiser!.delegate = self
}
func startAdvertising() {
advertiser!.startAdvertising(using: userName)
}
}
class Connector: ConnectionManagerDelegate {
func connectionManager(_ connectionManager: ConnectionManager, didReceive verificationCode: String, from endpointID: EndpointID, verificationHandler: @escaping (Bool) -> Void) {
verificationHandler(true)
}
func connectionManager(_ connectionManager: ConnectionManager, didReceive data: Data, withID payloadID: PayloadID, from endpointID: EndpointID) {
// TODO
}
func connectionManager(_ connectionManager: ConnectionManager, didReceive stream: InputStream, withID payloadID: PayloadID, from endpointID: EndpointID, cancellationToken token: CancellationToken) {
// TODO
}
func connectionManager(_ connectionManager: ConnectionManager, didStartReceivingResourceWithID payloadID: PayloadID, from endpointID: EndpointID, at localURL: URL, withName name: String, cancellationToken token: CancellationToken) {
// TODO
}
func connectionManager(_ connectionManager: ConnectionManager, didReceiveTransferUpdate update: TransferUpdate, from endpointID: EndpointID, forPayload payloadID: PayloadID) {
// TODO
}
func connectionManager(_ connectionManager: ConnectionManager, didChangeTo state: ConnectionState, for endpointID: EndpointID) {
switch state {
case .connecting:
// Handle connecting state
break
case .connected:
// Handle connected state
break
case .disconnected:
// Handle disconnected state
// Perform actions when the connection is
break
// Your code here
case .rejected:
// Handle rejected state
break
}
// TODO
}
let serviceId: String
let context: UIApplication
let callbacks: ConnectionCallbacks
let userName: Data
let strategy: Strategy
let connectionManager: ConnectionManager
var manualAcceptConnections: Bool
init(serviceId: String,
strategy: String,
context: UIApplication,
callbacks: ConnectionCallbacks,
userName: String = GeneralConstants.DEFAULT_USERNAME,
manualAcceptConnections: Bool = false) {
self.serviceId = serviceId
self.context = context
self.callbacks = callbacks
self.userName = userName.data(using: .utf8) ?? GeneralConstants.DEFAULT_USERNAME.data(using: .utf8)!
self.strategy = Connector.getStrategy(strategy)
self.manualAcceptConnections = manualAcceptConnections
connectionManager = ConnectionManager(serviceID: serviceId, strategy: self.strategy)
connectionManager.delegate = self
}
static func getStrategy(_ strategy: String) -> Strategy {
guard let connectionStrategy = ConnectionStrategies(rawValue: strategy) else {
return .star // Default strategy if not found
}
switch connectionStrategy {
case .P2P_CLUSTER:
return .cluster
case .P2P_STAR:
return .star
case .P2P_POINT_TO_POINT:
return .pointToPoint
}
}
}
from nearby.
Hi @bourdakos1 , could it be that this is failing again? Maybe there was a change in the library
[libprotobuf ERROR /Users/Username/Library/Developer/Xcode/DerivedData/Runner-gnvxrhyhjhcjfeebrolzpfvccdjm/SourcePackages/checkouts/nearby/third_party/protobuf/src/google/protobuf/message_lite.cc:134] Can't parse message of type "securemessage.SecureMessage" because it is missing required fields: (cannot determine missing fields for lite message)
[ERROR] VerifyDecryptPayload: error parsing SecureMessage.
[ERROR] DecodeMessageFromPeer: Failed to verify message.
Pretty much the same error
from nearby.
Hmm I don’t see any recent changes that would break things, but I’ll take a closer look tomorrow and try to reproduce
from nearby.
Thanks, let me know if I can be of any help!
from nearby.
@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
from nearby.
Hmm I’m not sure. Are you able to share any of the code?
from nearby.
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 discoverer.requestConnection
as in the docs).
In the advertiser device I can see this:
2024-03-07 23:06:29.657 Runner[664/0x16f7f3000] [lvl=2] base_pcp_handler.cc:1571() Connection accepted on Medium:WIFI_LAN
2024-03-07 23:06:29.657 Runner[664/0x16f9a3000] [lvl=2] bwu_manager.cc:190() InitiateBwuForEndpoint for endpoint SCF2 with medium WIFI_LAN
2024-03-07 23:06:29.657 Runner[664/0x16f9a3000] [lvl=2] endpoint_channel_manager.cc:176() Found WIFI_LAN Medium for endpoint:SCF2
2024-03-07 23:06:29.657 Runner[664/0x16f9a3000] [lvl=2] bwu_manager.cc:1419() CancelRetryUpgradeAlarm for endpoint SCF2
2024-03-07 23:06:29.657 Runner[664/0x16f9a3000] [lvl=2] bwu_manager.cc:253() BwuManager ignoring the upgrade for endpoint SCF2 because it is already connected over medium WIFI_LAN
[libprotobuf ERROR /Users/Username/Library/Developer/Xcode/DerivedData/Runner-ffqbzmukvbeqzmcphtrsuhwtsrzo/SourcePackages/checkouts/nearby/third_party/protobuf/src/google/protobuf/message_lite.cc:134] Can't parse message of type "securemessage.SecureMessage" because it is missing required fields: (cannot determine missing fields for lite message)
[ERROR] VerifyDecryptPayload: error parsing SecureMessage.
[ERROR] DecodeMessageFromPeer: Failed to verify message.
2024-03-07 23:06:34.675 Runner[664/0x170837000] [lvl=2] base_endpoint_channel.cc:158() Read: Read unencrypted KEEP_ALIVE on encrypted channel.
2024-03-07 23:06:34.675 Runner[664/0x170837000] [lvl=2] endpoint_manager.cc:210() KeepAlive message for endpoint SCF2
2024-03-07 23:06:34.675 Runner[664/0x170837000] [lvl=2] endpoint_manager.cc:210()
The last 6 lines are repeated every 5 seconds. On the other hand, in my discoverer device I can see this:
2024-03-07 23:09:34.982 Runner[22052/0x16f7b3000] [lvl=2] endpoint_manager.cc:192() Failed to decode; endpoint=BXRE; channel=WIFI_LAN; skip
2024-03-07 23:09:34.982 Runner[22052/0x16f7b3000] [lvl=2] endpoint_manager.cc:192()
2024-03-07 23:09:40.141 Runner[22052/0x16f7b3000] [lvl=2] endpoint_manager.cc:192() Failed to decode; endpoint=BXRE; channel=WIFI_LAN; skip
2024-03-07 23:09:40.141 Runner[22052/0x16f7b3000] [lvl=2] endpoint_manager.cc:192()
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!
from nearby.
The advertiser and connection manager code looks fine to me, do you have a code snippet for the discoverer side?
from nearby.
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 :)
from nearby.
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);
}
}
from nearby.
Related Issues (20)
- Memory usage continues to increase when receiving Payload
- Connection upgrade failure on Lenovo Tab M10 leads to constant disconnection HOT 3
- Unsafe dependency error while building an Xcode flutter project HOT 2
- Nearby networking really unstable with a large number of devices
- Nearby share source code HOT 1
- iOS NearbyConnections doesn't work with React Native HOT 7
- Reversing and Attacking Google Nearby HOT 2
- Need the help to activate my Fast Pair project
- Changes in NearbyShare as a result of merging with QuickShare HOT 1
- Device discovering itself after calling stopAdvertising HOT 1
- Entry point for using Connections API in a Windows app HOT 1
- Not able to find "webrtc/api/peer_connection_interface.h" HOT 1
- OnePlus Nord doesn't have any endpoint id, discarding. HOT 23
- Clarification on ultrasonic support HOT 2
- [Nearby Connections] error occurred when trying to send a file containing Non-ASCII values HOT 3
- Issue = invalid custom path 'third_party/protobuf/src' for target 'protobuf' HOT 2
- Fast Initiation - Windows to Android without Google Files app HOT 2
- BLE RSSI HOT 1
- BLE don't work betweeb Android (startDiscovering) and iOS (startAdvertising HOT 1
- An endpoint that never goes away (Low-Level) HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nearby.