I am attempting to create an application that uses the new M1 chip's UWB sensor to identify distance and bearing of connected devices in 3-D space. I have gotten to interact with the sensor locally, and generate a token for connection. When another device enables it's own sensor though, there is an error that prevents connection. The relevant console output is below:
## requestPermision
## start NearbyInteractionManager
## session = NISession
## session?.delegate = self <NISession: isSupported: YES, Token: E30B090973E326020A8033FB63EE9C803E68C14A3BB5786E2DBB, Configuration: null>
## MultipeerConnectivityManager.instance.delegate
## startBrowsingForPeers
## MultipeerConnectivityManager.instance.startBrowsingForPeers
...
## connected devices changed []
## session peer didChange
## discoveryTokenData
## connected to device : 307 bytes
## discoveryTokenData
## shareDiscoveryToken
2022-04-18 11:54:06.175774-0500 Proximity[7502:4557553] send data to 1 peers
2022-04-18 11:54:06.176141-0500 Proximity[7502:4557553] peer <MCPeerID: 0x283c205c0 DisplayName = Taylor’s iPhone> didChangeState: 2
## connected devices changed ["Taylor’s iPhone"]
## session didReceive
2022-04-18 11:54:06.178287-0500 Proximity[7502:4557553] didReceiveData: 307 bytes from Taylor’s iPhone
## data received
## Delegate session didInvalidateWithError : Error Domain=com.apple.NearbyInteraction Code=-5884 "User declined session." UserInfo={NSLocalizedRecoverySuggestion=Create a new session to prompt the user to allow., NSLocalizedDescription=User declined session., NSLocalizedFailureReason=The user declined to authorize the session.}
## session didInvalidateWithError : Error Domain=com.apple.NearbyInteraction Code=-5884 "User declined session." UserInfo={NSLocalizedRecoverySuggestion=Create a new session to prompt the user to allow., NSLocalizedDescription=User declined session., NSLocalizedFailureReason=The user declined to authorize the session.}
2022-04-18 11:54:15.910274-0500 Proximity[7502:4557743] [GCKSession] Not in connected state, so giving up for participant [7A766541] on channel [0].
2022-04-18 11:54:15.921590-0500 Proximity[7502:4557743] [GCKSession] Not in connected state, so giving up for participant [7A766541] on channel [1].
2022-04-18 11:54:15.927949-0500 Proximity[7502:4557743] [GCKSession] Not in connected state, so giving up for participant [7A766541] on channel [2].
2022-04-18 11:54:15.932892-0500 Proximity[7502:4557743] [GCKSession] Not in connected state, so giving up for participant [7A766541] on channel [3].
As you see, a relevant token is generated for my own session, but the connection to another device appears to be blocked. Permissions are requested at the beginning of the app and both phones accept as well.
I am new to the iOS framework and XCode since I primarily develop Unity products, as is the case for this project (it will be used in a mobile application) so I am hoping this is caused by something simple that I can research once I have a lead to go on. Google has not been helpful so far, but if you guys have any idea as to why this would be blocking permissions, please let me know. I can provide code as well if necessary, thanks!
Related
My web application is failing to gather WebRTC relay ICE candidates via a CoTURN server when using Safari 11 on iOS 11 (iPhone 5s & iPhone 7) or desktop. The web application (which establishes a one-way audio only WebRTC peer connection) works fine between the real browsers (Chrome and Firefox) either direct or via CoTURN relay, and I normally get 6-15 ICE candidates on these browsers.
I have a (frankly, unnecessary) call to getUserMedia on the receiving side, which allows host ICE candidates to be produced by Safari. (Note... the user must approve audio and/or video access before Safari will provide host Ice Candidates, even if on a receiving-only end. I'm past that hurdle, but just so you won't hit it too... This is out of "privacy" concerns.). Before I added the allow getUserMedia, I received no ICE. Now I receive two candidates. One with a private IPv4 and another with an IPv6. This is enough to get the app working properly when on the same machine or local network. So I'm pretty confident with other parts of the application code. I am not sure if my problem is with the application code or the CoTURN server.
Example of the ICE candidates received:
{"candidate":{"candidate":"candidate:622522263 1 udp 2113937151 172.27.0.65 56182 typ host generation 0 ufrag r23H network-cost 50","sdpMid":"audio","sdpMLineIndex":0,"usernameFragment":"r23H"}}
I pretty sure the RTCIceServer Dictionary for my RTCPeerConnection is inline with the following standards:
https://w3c.github.io/webrtc-pc/webrtc.html
https://www.rfc-editor.org/rfc/rfc7064
https://www.rfc-editor.org/rfc/rfc7065
And I've tried multiple variations of parameters:
// For Example:
var RPCconfig = {
iceServers: [{
urls: "turn:Example.live",
username: "un",
credential: "pw"
}]
};
// Or:
var RPCconfig = {
iceServers: [{
urls: "turns:Example.live",
username: "un",
credential: "pw",
credentialType: "password"
}, {
urls: "stun:Example.live"
}]
};
// And even more desperate attempts...
var RPCconfig = {
iceServers: [{
urls: "turn:Example.live?transport=tcp",
username: "un",
credential: "pw",
credentialType: "password"
}]
};
Here's an example of the signaling process log for an idea of what is going on. This is from the receiving side, which is Safari 11. The other browser was Chrome (compare 6 vs 2 ICE candidates). The state change refers to oniceconnectionstatechange.
SDP Offer received.
Sending signal SDP
Sending signal IceCandidate
Sending signal IceCandidate
ICE Candidate Received
4:08:25 AM State Change -> checking
ICE Candidate Received
ICE Candidate Received
ICE Candidate Received
ICE Candidate Received
ICE Candidate Received
4:08:40 AM State Change -> failed
CoTURN is configured quite liberally in terms of accepting every possible transport method as far as I am aware. It works well for providing ICE Candidates and as a relay for the other browsers.
Any direction would be greatly appreciated. Even if it is just a sample RTCIceServer Dictionary code that works or a proven TURN server to try.
I am new to ActionCable and sockets and trying to implement some real time features.
I successfully implemented real time notifications functionality (basic one) into my app, however there are a couple of things on which i spent some time to understand.
My Real time notifications code:
The authentification process:
# Connection.rb (using Devise)
module ApplicationCable
class Connection < ActionCable::Connection::Base
identified_by :current_user
def connect
self.current_user = env['warden'].user
reject_unauthorized_connection unless self.current_user
logger.add_tags 'ActionCable', current_user.email
end
end
end
Notification Channel:
class NotificationsChannel < ApplicationCable::Channel
def subscribed
stream_from "notification_channel_#{current_user.id}"
end
def unsubscribed
end
end
Notifications.coffee
App.notifications = App.cable.subscriptions.create "NotificationsChannel",
connected: ->
disconnected: ->
received: (data) ->
this.update_counter(data.counter)
# if use_sound is "true" play a mp3 sound
# use_sound is sent ("true" or "false") because when a notification is destroyed we don't want to use sound only update counter
if data.use_sound == "true"
$("#sound-play").get(0).play()
# Update Notifications Counter and change color
update_counter: (counter) ->
$("#notifications-counter").html("#{counter}")
if counter > 0
$("#notifications-counter").css('color','#FFA5A5')
else
$("#notifications-counter").css('color','white')
And there is the Job file where we broadcast to the channel with Notifications Counter
Note: I only send notifications count because in the nav-bar when the user clicks the (ex. 2 Notifications) - button, a dropdown is toggled and populated via AJax call.
My questions are:
Is it normal to have all the time 'GET /cable' requests with the response 'An unauthorized connection attempt was rejected' when a user is not logged in ( I understand that the current_user in the Connect.rb file is set from the cookie, but when a user is on ex Home page, Logg-in page, etc.. basically not authenticated.
In the server logs I can see every 1,2 seconds the GET /cable
Is this normal? I'm thinking that somehow I have to stop this if the user logs out or something.
When I start the server I get the following error for like 10 seconds till the server starts in the browsers console. Since the notifications work, I don't know if this is a problem of not, but an error it is.
WebSocket connection to 'ws://localhost:3000/cable' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
I even tried setting config.action_cable.mount_path = "/cable" or "ws://localhost:3000/cable" and did not fix it.
Next I want to implement a chat, where 2 users can have a private conversation, is the "current_user" defined in the Connection.rb 'secure', how can I add authorization to ActionCable or something like. In the rest of my app I'm using CanCan Gem and works perfectly.
Thank you very much for the time invested in reading the question. If you have answers for my questions I will really appreciate them. And if you have some directions to give or tips for building a complex and secure chat with ActionCable I would love to hear them. Thank you!
I think what you want to be looking at is the cable.js file where the createConsumer function is called.
Creating a consumer is what subscribers a user to the channel. I think you need to focus on when this code gets called.
You are using user authentication's presence to reject unauthorised use.
This is very good, however not so great when the JS consumer is created for any visitor (i.e. cable.js is loaded into application.js for all pages).
What you can do is use content_for into a seperate layout for authenticated users that calls the cable.js to create a consumer and ensure that cable.js does not get included into unauthorised pages.
I want to intercept the offline message of mod_pubsub, if I send a normal message in ejabberd to offline user, I see that message in offline odbc table, if user reconnect the message arrive.
If I publish to a node, and some user are offline, I see nothing in offline message table, but if the user reconnect the item node is sent correctly so the message is saved somewhere.
Can I send the item offline to offline message odbc table? or can I intercept the offline item of mod_pubsub like for message, in fact for message from plugin I can do this:
start(_Host, _Opt) ->
inets:start(),
ejabberd_hooks:add(offline_message_hook, _Host, ?MODULE, create_message, 50).
stop (_Host) ->
ejabberd_hooks:delete(offline_message_hook, _Host, ?MODULE, create_message, 50).
this is my ejabberd.yml config for mod_pubsub:
mod_pubsub:
access_createnode: pubsub_createnode
## reduces resource comsumption, but XEP incompliant
ignore_pep_from_offline: true
## XEP compliant, but increases resource comsumption
## ignore_pep_from_offline: false
last_item_cache: false
db_type: odbc
plugins:
- "flat"
- "hometree"
- "pep" # pep requires mod_caps
As default, pubsub message type are headline. As per XMPP specifications, headline messages should not stored in offline message store.
However, there is a mod_pubsub option to change default notification type. You can for example set mod_pubsub notification_type option to normal. Normal messages are store in offline store.
How can I prevent receiving the same message in MQTT what the same client has published?
Problem:
Client1 subscribes: site1/feeds/#
Client1 publishes: site1/feeds/one
Client1 receives: site1/feeds/one <- how can I prevent this on the local client?
Client2 publishes: site1/feeds/two
Client1 receives: site1/feeds/two <- this I want to keep
As Bubbafat said you can't prevent this at the protocol level and I'm not aware of any brokers that implement this as a feature.
Your only real option is to add a filter in the onMessage callback
I wrote two small programs which tried to acquire the same Remote Mutex named "The Token":
ACE_Remote_Mutex token("The Token", 1, 1);
token.acquire();
ACE_OS::sleep(5);
token.release();
return 0;
Both of them got the following debug output:
(3078597488) acquired The Token
(4243|3078597488) BIG PROBLEMS with get_connection: Connection refused
error on remote acquire, releasing shadow mutex.
(3078597488) released The Token, owner is no owner
(4243|3078597488) BIG PROBLEMS with get_connection: Connection refused
(3078597488) release failed: Permission denied.
(3078597488) shadow: release failed
Does ACE_Remote_Mutex work only with some sort of "agent" like Corba broker? Can I modify my code?
Remote_Mutex uses Token Service to acquire lock. Token Service is not a CORBA service but it plays a role similar to it. Here is an example of svc.conf entry that starts Token Service dynamically:
dynamic Token_Service Service_Object *
../lib/netsvcs:_make_ACE_Token_Acceptor()
"-p 10202"