WebRTC Joining room - webrtc

Currently developing a WebRTC app,(local at the moment),
I used the codes of Muaz Khan as a starting point, Muaz Khan GitHiub
My problem is when i quick join the room with multiple tabs on my screen, +/- 1/5 does not join the room.
This does not happen all the time but alot.
when i reload the tab wich did not joined, and try it again, it works fine.
My own project has the problem and the muaz khan demo has it too.
The error in console log:
Uncaught TypeError: Cannot read property 'split' of undefined
the function in the WebRTC library:
function isEmpty(session) {
var stringified = JSON.stringify(session);
if (stringified === '{}' || !stringified.split(',').length) {
return true;
}
return false;
}
Can't find what's wrong because this error happens often, but not every time..

So, you're talking about this.
I'll suggest following demo, which is having following advantages:
Reliable connection for open/join rooms. It NEVER fails.
Auto reconnects if socket.io connection fails.
Reliably keeps room opened even if moderator leaves.
To install it in linux based systems:
mkdir rmc && cd rmc
wget https://cdn.webrtc-experiment.com/packages/rtcmulticonnection-client.tar
tar -xf rtcmulticonnection-client.tar
node server
Now it runs on port 8080.
You can even directly download the TAR or ZIP.

Related

Direct Messages fail with Status: 501 Payload: Null

I have a dotnet core project running version 1.37.2 of Microsoft.Azure.Devices.Client on top of Linux Raspbian (Buster 5.4.83) on a RaspBerry Pi4B 2GB. The project sends telemetry every 5 mins to Azure IoT Hub. The project also registers a number of Direct Methods to be called using 'SetMethodHandler' as follows:
await _iotHubClient.SetMethodHandlerAsync("MethodToCall", MethodToCallHandler, null);
I have a number of devices out in the real world, connected to the internet over wireless LAN and standard home internet connections.
I have noticed that some devices I can call DirectMethods on relatively reliably some I have to often try three of four times before I get a successful response and others I am never able to call successfully. When the DirectMethod calls fail I always receive {"status:501", "payload":null}.
Any help appreciated.
Do you have the same code\version deployed on both devices that work and don't work? 501 usually stands for "Not Implemented." In azure-iot-sdk-csharp you can read the following for 501 Error Code:
"Equivalent to HTTP status code 501, not implemented server error. It
is used when a method call from the service specifies a method name
not registered with the client for callback."
Ref: https://github.com/Azure/azure-iot-sdk-csharp/blob/master/iothub/device/src/MethodResponseStatusCode.cs#L21
some I have to often try three of four times before I get a successful response and others I am never able to call successfully.
Before you can call the methods successfully on those devices do you ever receivie a 501 error or you receive those as described here (404 or 504)? If never seeing 501 errors on "working devices" then you need to make sure you have same versions of the code deployed on "non-working devices".

vue.js - view index.html without a server

I'm building an app with vue.js and this app needs to run later on a terminal without internet connection and without a running server. I want that my client just have to start the index.html file. Is this possible and what setup do i need?
When i start the index.html my only error message in console i get is:
Uncaught DOMException: Failed to construct 'Worker': Script at 'file:///xxx/dist/ec0098eb6371c2f4342a.worker.js' cannot be accessed from origin 'null'.
my register-service-worker.js looks like this to allow localhost
if (
process.env.NODE_ENV === 'production' &&
('https:' === location.protocol || location.host.match(/(localhost|127.0.0.1)/)) &&
navigator.serviceWorker
) {
navigator.serviceWorker.register('/service-worker.js');
}
i try now for days to find a solution. I already build half of my app and now i see that
it can't run locally. I hope someone knows a trick.
Thanks from Germany
A service worker needs https or localhost to work. It will not work in file:// etc. (https://developers.google.com/web/fundamentals/primers/service-workers)
For a one click start you could start such a server from a batch file, but you would have to assume your client has Node or python installed, then npx http-server or the like would work.
Lastly, if your App is completely offline and without a server, you might not need a service worker in the first place.

How to connect ioredis to google cloud function?

I am currently running some Google Cloud functions (in typescript) that require a connection to a Redis instance in order to LPUSH into the queue (on other instances, I am using Redis as a queue worker).
Everything is fine, except I am getting a huge number of ECONNECTRESET and ECONNECTIMEOUT related errors despite everything working properly.
The following code can execute successfully on the cloud function but still, I am seeing constant errors thrown related to the connection to the Redis.
I think it is somehow related to how I am importing my client- ioredis. I have utils/index.ts, utils/redis.js and inside the redis.js I have:
const Redis = require('ioredis');
module.exports = new Redis(6380, 'MYCACHE.redis.cache.windows.net', { tls: true, password: 'PASS' });
Then I am importing this in my utils/index.ts like so: code missing
And exporting some aysnc function like: code missing
When executing in the GCF environment, I get the # of expected results in results.length and I see (by monitoring the Redis internally) this list was pushed as expected to the queue.
Nevertheless, these errors continue to appear incessantly.
ioredis] Unhandled error event: Error: read ECONNRESET at _errnoException (util.js:1022:11) at TLSWrap.onread (net.js:628:25)

WSO2 EMM Agent with COSU not using NFC

I have built the latest version of wso2 emm android agent (cdmf-agent-android v3.1.30) and got some initial tests working in BYOD mode with IoT server 3.1.0
When built for COSU it is waiting for provisioning with another device via NFC. But I want to provision devices without NFC. What options do I have? Could I trigger programmatically a custom provisioning option?
There are some options to do this, depending on your android version.
I will start with the simplest option. If you have Android 7+ you can use QR Code provisioning, this follows the exact same process as NFC provisioning. You can see some specifications from Google regarding this.
The second option is a bit trickier and requires some custom dev on your side. First thing to to make your device a Device Owner (Which is needed for COSU mode, read up about Device Owner here). Using the command: adb shell dpm set-device-owner org.wso2.iot.agent/org.wso2.iot.agent.services.AgentDeviceAdminReceiver
Note: Only one device owner can be set, to remove a device owner the device has to be factory reset.
Once this is done you can launch your app using adb shell am start -n "org.wso2.iot.agent/org.wso2.iot.agent.activities.SplashActivity".
The above will get your app to run correctly but now it has to authenticate itself to communicate to the server. When using NFC provisioning an Access Token is delivered in the Extra Bundle as 'android.app.extra.token', you can insert this extra in the launch intent as follows: adb shell am start -n "org.wso2.iot.agent/org.wso2.iot.agent.activities.SplashActivity" --es android.app.extra.token generated_access_token. You will have to edit the SpashActivity class to accept this token and follow the general authentication processes built into the app.
This may be a little bit late but I hope it is still helpful!
Some extra information you may appreciate, here is a string representation of the NFC message used, these are the specifications set in the NFC Provisioning App:
`
#Thu Apr 12 13:42:11 GMT+02:00 2018
android.app.extra.PROVISIONING_LOCAL_TIME=1523533331087
android.app.extra.PROVISIONING_TIME_ZONE=Asia/Colombo
android.app.extra.PROVISIONING_SKIP_ENCRYPTION=true
android.app.extra.PROVISIONING_WIFI_SECURITY_TYPE=WPA
android.app.extra.PROVISIONING_WIFI_PASSWORD=PASSWORD
android.app.extra.PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION=LOCATION_OF_APK
android.app.extra.PROVISIONING_WIFI_SSID="WIFI_SSID_NAME"
android.app.extra.PROVISIONING_LOCALE=en_US
android.app.extra.PROVISIONING_DEVICE_ADMIN_PACKAGE_CHECKSUM=E8PtiqUOcqKi5IXeRBF-5Br0zXg
android.app.extra.PROVISIONING_ADMIN_EXTRAS_BUNDLE=\#admin extras bundle\n\#Thu Apr 12 13\:42\:11 GMT+02\:00 2018\nandroid.app.extra.token\=GENERATED_ACCESS_TOKEN\n
android.app.extra.PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME=org.wso2.iot.agent
`
An example of a QR Code representation would be:
`
{
"android.app.extra.PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME": "org.wso2.iot.agent/org.wso2.iot.agent.services.AgentDeviceAdminReceiver",
"android.app.extra.PROVISIONING_DEVICE_ADMIN_SIGNATURE_CHECKSUM": "CSGeivCEHdJrPT0qy4W67LZSy32Fus7GyUn0jE5o028",
"android.app.extra.PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION": "APK_DOWNLOAD_LOCATION",
"android.app.extra.PROVISIONING_SKIP_ENCRYPTION": false,
"android.app.extra.PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME": "org.wso2.iot.agent",
"android.app.extra.PROVISIONING_ADMIN_EXTRAS_BUNDLE": {
"android.app.extra.token":"GENERATED_ACCESS_TOKEN"
}
}
`

Mac OS X XPC as IPC between two applications

I have a windowed application and windowless helper, sitting inside the app bundle, and working as login item. App can start and stop the helper, everything woks there. The problem is that I need to create some bidirectional communication channel between them. And it should work in both sandboxed and not sandboxed versions, desirably in OS X 10.7+.
I've investigated the topic and find that XPC can provide peer-to-per connection. I've read related Apple docs, as well as few topics below:
Is possible to use Mac OS X XPC like IPC to exchange messages between processes? How?
Communicate with another app using XPC
http://afewguyscoding.com/2012/07/ipc-easy-introducing-xpc-nsxpcconnection/
https://www.objc.io/issues/14-mac/xpc/
But I can't find any description of how should I organize my XCode project. I have two targets: "Main App" and "Helper App". Now I need to add the third one, taking XPC Service, as a template. OK, but what to do next? Where this XPC bundle should be located to be available for both applications? Note, that helper sits in the main app bundle, as it's a login item. So, I need some clear instruction or just a XCode project sample.
Thanks,
Alex
Alright for anyone that has been struggling with this, I was finally able to 100% get communication working between two application processes, using NSXPCConnection
The key to note is that you can only create an NSXPCConnection to three things.
An XPCService. You can connect to an XPCService strictly through
a name
A Mach Service. You can also connect to a Mach Service
strictly through a name
An NSXPCEndpoint. This is what we're
looking for, to communicate between two application processes.
The problem being that we can't directly transfer an NSXPCEndpoint from one application to another.
It involved creating a machservice Launch Agent (See this example for how to do that) that held an NSXPCEndpoint property. One application can connect to the machservice, and set that property to it's own [NSXPCListener anonymousListener].endpoint
Then the other application can connect to the machservice, and ask for that endpoint.
Then using that endpoint, an NSXPCConnection can be created, which successfully established a bridge between the two applications. I have tested sending objects back and forth, and it all works as expected.
Note that if your application is sandboxed, you will have to create an XPCService, as a middle man between your Application and the Machservice
I'm pretty pumped that I got this working-- I'm fairly active in SO, so if anybody is interested in source code, just add a comment and I can go through the effort to post more details
Some hurdles I came across:
You have to launch your machservice, these are the lines:
OSStatus err;
AuthorizationExternalForm extForm;
err = AuthorizationCreate(NULL, NULL, 0, &self->_authRef);
if (err == errAuthorizationSuccess) {
NSLog(#"SUCCESS AUTHORIZING DAEMON");
}
assert(err == errAuthorizationSuccess);
Boolean success;
CFErrorRef error;
success = SMJobBless(
kSMDomainSystemLaunchd,
CFSTR("DAEMON IDENTIFIER HERE"),
self->_authRef,
&error
);
Also, every time you rebuild your daemon, you have to unload the previous launch agent, with these bash commands:
sudo launchctl unload /Library/LaunchDaemons/com.example.apple-samplecode.EBAS.HelperTool.plist
sudo rm /Library/LaunchDaemons/com.example.apple-samplecode.EBAS.HelperTool.plist
sudo rm /Library/PrivilegedHelperTools/com.example.apple-samplecode.EBAS.HelperTool
(With your corresponding identifiers, of course)