OpenTok, detect if remote subscriber has poor connection or temporarily disconnected or network disconnected for Android and iOS SDK - opentok

We are not able to detect subscribers'/clients' disconnected signal or poor network connection with Android/iOS SDK, however, we are able to detect with OpenTok web (JS).
The below link suggested for the web which is working fine our end too, but we need the same for OpenTok Android and iOS SDK.
Determining if a remote subscriber is temporarily disconnected.
we need sample code to detect poor connection or network disconnected at subscribers end for both Android and iOS. if anybody faced a similar problem and has a workaround then please suggest.
our aim to show messages on the mobile phone if subscribers have poor connection issues or trying to reconnect.

There are analogous re-connection callbacks for Android and iOS as well. Reconnection callbacks get triggered when a client tries to automatically reconnect after losing its connection to an OpenTok session. Otherwise, if a client cannot reconnect, the SessionListener's "disconnected" method gets triggered.
To verify if session reconnect APIs are working fine at your end, we recommend you to implement the necessary callbacks and manually check if the registered callbacks gets triggered or not by disconnecting network and then reconnecting it again.
Please checkout the below link for implementing callback APIs:
Android:
https://tokbox.com/developer/sdks/android/reference/com/opentok/android/Session.ReconnectionListener.html
iOS: https://tokbox.com/developer/sdks/ios/reference/Protocols/OTSessionDelegate.html#//api/name/sessionDidBeginReconnecting
Hope it helps!

Related

Sonos control api: polling rate & subscription

We are controlling the sonos via a small IOT device. This device will be placed at the homes of our customers.
In our home automation system we need to know the playbackstate + volume of the players/groups.
At which polling rate can we ask these parameters ?
We cannot use a cloud server to handle the subscription events.
I tried to put a https webservice in the IOT device with a self signed certificate but this doesn't work.
After I have posted the subscription I get a request in my webservice but the cloud sonos server disconnects immediately.
Probably because of the certificate is self signed - Or can there be another reason ?
Is there another way to recieve status events ?
During discovery In the players Json object there is a key 'websocketUrl'.
The documentation says "The secure WebSocket URL for the device. See Connect for details".
But I cannot find more info about this.
Can this be used ?
At which polling rate can we ask these parameters?
Consider using subscriptions instead of polling. See this answer for more: https://stackoverflow.com/a/60893119/4902948
We cannot use a cloud server to handle the subscription events...
Or can there be another reason?
Is there another way to [receive] status events?
You must host a service that satisfies a set of requirements to receive events. See this answer for more: https://stackoverflow.com/a/57189717/4902948
Also see Details on API credentials and events in New features in versions 11.1, 11.2 (S1), & 12.0 (S2).
Can [the 'websocketUrl'] be used?
This is not publicly available for use.
It would be a lot easier to use the (undocumented but more useful) UPnP APIs. You could simply Subscribe to the UPnP RenderingControl endpoint, then you will get an event every time the volume changes. To find when the track changes, subscribe to AVTransport endpoint.
You can do this with a local server (this is how every Sonos app works after all) and no special cert requirements either.
UPnP events are described in the UPnP spec.
Your question doesn't provide details about the language you're using, but if the device is powerfull enough to run node, you have a good change with my sonos library.
You can just pull the required information from the device as often as you like. Or use the build-in event subscriptions. If you use the events, it will automatically setup an http listener and automatically subscribe to all the events you're listening for.
Events are instant (as in 50ms-100ms after the event took place on the device).
If you request information it is send directly to the device and the device will respond with the answer. Pulling multiple data points per second has never been a problem to me.
Warning as stated above, this uses the undocumented local UPNP api, but since their own app also uses it, I'm guessing that won't change soon.

Azure SignalR not working on few types of phone

I am developing a Xamarin Forms app for Android where in i need to receive events from server using Azure SignalR function. This is working fine in few phones, however on few I get strange errors.
Redmi 4 running Android 7.1 I see that the connection is successful, it it does not receive any messages.
Redmi 1s running Android 4.4 KitKat, it gets connected and I can receive messages, however soon it gets disconnected stating that remote party closed the websocket connection without completing the close handshake or 30000 ms elapsed without receiving a message from server
BTW I have a background Service where I am creating this SignalR Hub and connecting so that even if my app goes to sleep, I can still receive the server events.
it works fine on some of the other newer phones in my home. so my question is what is the best way to debug these kind of issues. I don't see any logs in the Device Log that can help me understand what is going on.

Reconnect websocket/mqtt after client internet disconnection

I am setting up an MQTT/Websockets server, my client is an flutter app, which connects to the broker on main screen, and in other screens it sends and receive messages from the broker. My understanding of keepAlive is how often the client and server should share ping/pong, so they make sure the connection is still alive. being said, if my flutter app, connects to the broker in main screen, of 3600/1 hour keepAlive, and suppose to share and receive messages on other screens, if i disconnect the client from the internet for 2 minutes, and reconnect after that, it will not send/receive messages, maybe my understanding of keepAlive is not correct. Well, How would i structure my app/server to reconnect automatically to the internet as soon as internet connection is back and up again.
I have also tried On.Disconnect method, which i noticed it will never get called, and the app even though still thinks its connected to the broker.
I mentioned websockets, on the tags as i could do mqtt over websockets.
I see that no-one else has responded, so I'll try (however I'm new to this also).
Also, have you looked at the Flutter connectivity package?
From my reading of the Mqtt specification, it seems the Mqtt client ** should** disconnect the TCP/IP connection if it doesn't receive a PINGRESP to its PINGREQ in the keep alive period (ie it's not required to disconnect).
My Flutter + Mqtt app checks the connection state, and reconnects if needed, every time it sends a message. I haven't needed to check for internet dropouts, but I have noticed the connection is lost on some application state changes. The main app widget. is notified of these using didChangeAppLifecycleState() and sends a dummy message if needed.
So this doesn't answer exactly what you asked, but I hope it's useful anyway.

OpenTok TokBox: How can I automatically start a live streaming (rtmp) broadcast of a session when the first connected user publishes?

I've seen the sample app on github. There is an explicit "Start Broadcasting" button that does what it sounds like (starts broadcasting rtmp).
I'd like not to have an explicit button. I'd like to start broadcasting when the first user in a session publishes his or her camera. So if 5 users connect to the session, call broadcast when the first of them publishes a stream, but not when any of the others do.
Can I query the session and know whether it is live streaming currently? What is the best practice here? Thanks.
TokBox Developer Evangelist here.
You cannot query the number of active streams in a Session, you would have to store that information on your own as events are being dispatched. Please see this SO answer for more details: #OpenTok how enumerate streams in a session?
As for broadcasting, you can start broadcasting programmatically when the first person starts publishing instead of using a visual component to trigger the call. For example, on the client side, you can listen for the streamCreated event and then send a request to your application server to start the broadcast. Your application server would then have to make a the startBroadcast call to OpenTok via a Server SDK or using the REST API.
Alternatively, you could use Session Monitoring to listen to Stream and Connection events on the server via a webhook, to start the broadcast.
To find out more on how OpenTok Broadcasting works, I recommend checking out the following resources:
OpenTok Broadcasting Developer Guide
OpenTok Broadcasting Webinar

Windows does not answer BLE parameter update request

I have a custom embedded device with a Bluetooth low energy stack. The device is advertising itself until a connection is requested, I pair and connect to it via the Bluetooth menu in Windows 10, I can read/write to my custom GATT services using the following BLE GATT functions from the Win32 API.
For my application I need to receive high frequency data using notifications on a characteristic so I enable it using the same API as stated above and receive the correct data but too slow. The default connection parameters Windows is using is not enough and I want to update them so I can receive notification events at higher frequency, but Windows API does not provide such function. I had the same problem when connection to an Android phone, and I solved it by requesting connection parameters update from the device (the slave in the connection) and the Android phone accepted it and everything worked as expected.
The only problem is when I'm trying to ask for a connection parameter update from the device when connected to a Windows master, I don't receive any response (no accept nor reject), meanwhile I still receive notification events so I know the connection is still active. And the weird thing is that if I hold the device closer to the computer's Bluetooth antenna it does receive a response and update the connection parameters like intended.
Any idea what's going on? Is it a bug in Windows stack?
The fact that holding device closer to antenna helps should be verified. Try it multiple times in a different way.
You mentioned Android, does holding device further from Android also prevent connection parameters update?
If this proves true, I'd say the device is faulty. I would compare the behavior between different devices, better if they are from different manufacturers or at least models.

Resources