Keep RID in sync with multiple tabs for Strophe js connection - connection

We are trying to implement a chat application where we are using strophe js for http-bind. Everything works fine, the only problem we are facing is with keeping connection alive with multiple tabs. I am not getting how to keep RID in sync when multiple tabs are open. Please help!!

Each requesting resource should have it's own resource name. In your instance, each tab should have it's own resource name and connection.
username#jabber.servername.com/tab1
username#jabber.servername.com/tab2
You will then need to cc any messages to each resource to keep them up to date with messages. See: http://xmpp.org/extensions/xep-0280.html. Each resource will then have it's own RID.

Related

Keeping webrtc streams/connections between webpages

I have a specific issue where I'm using WebRTC (voice and video).
I want to keep a connection/voice/video streams alive between webpages on a website. I thought I could use shared web workers to run in the background?
Any guidance would be great. I've looked at other posts but they're quite old and wondered if anyone had any, more, up-to-date information or ways I could tackle this issue?
UPDATE:
Shared Web Workers are the incorrect way of tackling this problem. Service Workers are the way forward for maintaining after the web page is terminated.
Keeping the webRTC connection alive between page loads seems like a rare use case. Normally, you start a call and remain on a single page. I guess it could make sense if you wanted to embed a customer support like webRTC widget on a site and have that widget follow a user through page navigations under a single domain.
I don't think saving/reusing the blob URL will allow you to reconnect on a page reload for security issues/hijacking potential.
There is the IceRestart constraint which might help. Apparently you can save the SDP info to local storage, reuse the negotiated SDP, then call an IceRestart to quickly reconnect.
As described in section 3, the nominated ICE candidate pair is
exchanged during an SDP offer/answer procedure, which is maintained
by the JavaScript. The JavaScript can save the SDP information on
the application server or in browser local storage. When a page
reload has happened, a new JavaScript will be reloaded, which will
create a new PeerConnection and retrieve the saved SDP information
including the previous nominated candidate pair. Then the JavaScript
can request the previous resource by sending a setLocalDescription(),
which includes the saved SDP information. Instead of restart an ICE
procedure without additional action hints, the new JavaScript SHALL
send an updateIce() which indicates that it has happended because of
a page reload. If the ICE agent then can allocate the previous
resource for the new JavaScript, it will use the previous nominated
candidate pair for the first connectivity check, and if it succeeds
the ICE agent will keep it marked as selected. The ICE agent can now
send media using this candidate pair, even if it is running in
Regular Nomination mode.
https://bugs.chromium.org/p/webrtc/issues/detail?id=979
https://datatracker.ietf.org/doc/html/draft-li-rtcweb-ice-page-reload-02

Solution for Web Application with Unreliable Internet Connection

We've developed a web application which is hosted on premises available for people in the shop floor via Wifi. However, the wifi signal is not reliable and it's not possible to use wired network or improve the signal.
I am looking for a solution to handle this issue. Is there a way to put the http requests into a local queue and process it asynchronously at the background? If so, how to do it? Or is there any other alternative approach?
Any thoughts are greatly appreciated.
I have the same problem in the company where I work, there are certain places where the WiFi can not reach, and the system needs to get information from the DB in order to show that info to the user and then upload some new info.
Part of this system is done with iPads, so to solve the problem I use LocalStorage to store a JSON object that contains the info the user need to work, I store the info that is going to be uploaded in another JSON object, and when there is a connection available the info is Uploaded.
Hope it helps
I would recommend to build the web app with angularjs or another javascript framework of your choice. Once the user has loaded the site you can perform asynchronous ajax/http requests to load the required data and the web app will never reload the entire page.
In case one http request fails you can implement that the web app should try one more time or whatever :)

Rails, BOSH, XMPP should I manually increase rid?

I have installed ejabberd on my system and gems 'xmpp4r', 'ruby_bosh'. I'm trying to make a chat client using strophejs in my views. Now I'm getting jid, sid and rid with BOSH and can save them in session using in view after this all.
So I'm connecting strophejs to http-bind like
var connection = new Strophe.Connection('http://localhost:5280/http-bind/');
and trying to attach my session like
connection.attach("#{bosh_session_jid}", "#{bosh_session_id}", "#{bosh_session_random_id}", function(status){
console.log(status);
});
bosh_session_jid, bosh_session_rid and bosh_session_sid are this identifiers that I should use and they are not changed.
So, at first connection attempt everything is connected and working ok and I even can send message. But after window reloading (F5 I mean) it's trying to reconnect and reattach process and sends me
POST http://localhost:5280/http-bind/ 404 (Not Found)
I read "Professional XMPP programming with JS and jQuery" and found line
Each subsequent request increments the RID by one.
So, do I need to increase rid by 1 in my cookies after each attach? Or then? Or I don't need to?
You must increment the RID yourself when refreshing or changing pages. I increment by 1 when loading the new page before attaching. Note: if you are storing in a cookie, you should update with every call returned with the new RID, so that your cookie is updated with the most current RID.

Little Snitch reports my app (when run in simulator) wants to connect to random websites

I have an app that uses a web service to get data. I hit one site for the data, passing in various parameters/methods depending on what data I need. The base URL of the site is always the same. I'm using AFNetworking whenever I get/receive data.
When I launch my app in the iOS simulator, Little Snitch indicates that my app wants to connect to a couple of sites - sites that are not in my code!
Example sites Little Snitch has indicated:
www.tv.com
common.publicradio.org
Anyone know why this happens?
EDIT:
I'm only hitting some Cold Fusion methods at http://www.acquisign.com no other sites. The Acquisign site has no links to any of the mentioned sites. I load no web pages, just get JSON back from the CF methods invoked at the Acquisign site.
EDIT 2:
More info:
I've fond that this has to do with OpenDNS. If I set my network to not use OpenDNS, I don't get these random connection warnings from Little Snitch and my app. (Today it wanted to connect to home depot.com and relish.com).
OpenDNS is most likely responding to a non-loading page request with a page of link suggestions. I now wonder what the non-loading page is - as I only hit one site and get JSON back and the JSON contains no other URLS....

signalR no element found error message

On pages that I have signalR included I get the following error in firebug:
http://localhost:53604/signalr/signalr/negotiate?_=1352797361490
no element found
everything still works fine but just wanted to see if this will become an issue. thanks
Since you're using Firebug that means you're using Firefox. What transport are you using (if using Fiddler remember to turn Streaming on)? It should be:
1. Long Polling
2. Server Sent Events
3. WebSockets
If the transport is Long Polling then we probably have an issue in the underlying code(Firefox should prioritize WebSockets/SSE before LP).
However, if not then we have a content based issue. So that being said, what type of data are you retrieving from the server? Usually a no element found error comes from invalid markup.
Try stripping out all pieces of your application and see if you still get this error. AKA just a $.connection.hub.start().

Resources