We are making a website where we are trying to develop a chat application, we have already built one using Comet, however due to speed factors we decided to make one in XMPP.
However, with HTML5 alive and living and the new websockets technology in existance, should we leave XMPP and try making using Websockets instead?
So my questions are :
I can make a mobile app and connect it to XMPP on my server, is
there a way to connect to a websockets based chat app via phone? (
For example Smack library for android, is there something similar
for websockets based app?
Is there a fallback option say if the person is using an old browser
for the websockets based chat app?
Which has more overhead and which technology is faster or better?
Also, it may be said that XMPP is a tried a tested technology, it still needs many libraries right? Such as the Strophe.js flXHR etc. right? But isin't HTML5 built for this type of thing without any eternal libraries etc?
Regards,
The XMPP wikipedia page has a section on XMPP via HTTP and WebSocket transports. The last paragraph states:
A perhaps more efficient transport for real-time messaging is WebSocket, a web technology providing for bi-directional, full-duplex communications channels over a single TCP connection. Experimental implementations of XMPP over WebSocket exist, and a (now-expired) Internet-Draft documenting this approach was published at the IETF but not yet standardized.
WebSocket is a protocol for messaging and as such XMPP can be implemented over WebSocket. If WebSocket sub-protocols are taken further we may even see native support for this. But until then the WebSocket connection would simply act as the low-level transport for the XMPP protocol messages.
So, it's not a question of "XMPP or WebSocket". If XMPP fits your requirements well then I'd look for an solution that uses WebSockets (and has appropriate HTTP fallbacks) and provides XMPP support.
Related
I have been studying WebRTC from last 2 days but couldn't understand how to develop and stand up a server based on WebRTC for iOS.
I really don't want to use any 3rd party Audio/Video chat service providers in my application even if they are WebRTC based. I want to create my own WebRTC based custom Audio/Video chat.
I just need a startup guide for developing WebRTC based chat server.
Couple of things:
You will have to work with the NativeAPI and compile for iOS, this tutorial should help, this is for the iOS client side only.
If you chat is only one-to-one a simple websocket or socket.io with node.js for your signalling server should be simple enough
If you want numerous parties in the same chat, you will either have to handle all the individual connections(numerous individual peer connections for each device connecting) or implement a type of MCU, licode is an EXAMPLE of such
Those links are just examples of how people have done similar things before, you should not have to utilize their libraries or their solutions. But, you WILL have to use the WebRTC Native API, handle numerous peerconnections for each client(or create your own MCU server), and handle the signalling between each client(for connection start up and tear down).
You can also try Icelink api provided by Frozen mountain
They have provided free trials for iOS, android , web client, windows phone.
Also they have provided their own turn and stun servers which can be only used in windows server 2013. Overall library is very well documented and easy to use.
You need to register yourself to download the api, which is free of cost.
Hope it meet your requirements.
Good luck
I am trying to create a web chat application with PHP, MySQL.
I want to stream the data from the server to client instead of requesting the server in a regular intervals which will cause huge load at servers.
I believe this is possible in many ways and XMPP is one of those i heard earlier, but i have no idea how to adopt this xmpp into scripts, how to use it?
If some one can give some examples or code references that would be great help.
Please check the documentation of XMPP,
All the social media sites including Google facebook uses XMPP in their instant messaging.
For working with XMPP on client side, you can either use websockets or http bind(aka bosh) based on your requirements and support from the xmpp server. I have tried and experimented with trophyjs and Candy.Js. Candy being slightly better in terms of plugins and support if you like chat rooms.
I am developing a php based website. i want to implement Facebook chat in it.
My question is that how i can use XMPP with BOSH. what is the relation of XMPP and BOSH.
is there any sample source code to get idea how to implement Facebook chat using library such as JAXL or strophe.js
My question is that how i can use XMPP with BOSH. what is the relation
of XMPP and BOSH.
BOSH stands for bidirectional stream over http. It is a specification designed for running XMPP over HTTP, but can be used to run any underlying tcp level protocol over http.
BOSH basically plays within the limitations of the browser i.e. one cannot make more than 2 requests to a particular domain at a time. And within these limits, BOSH is able to emulate a full blown bidirectional pipe between server and the client. Payload can be transmitted using this virtual pipe and user experience wise it is as good as real-time.
Traditionally BOSH is emulated using a technique called long-polling. However, i have successfully been able to run the same using jsonp and websockets (if available).
is there any sample source code to get idea how to implement Facebook
chat using library such as JAXL or strophe.js
I bet you will find enough sample examples of a web chat application using strophe.js. All you need is a bosh connection manager like punjab or ebosh (one i wrote), which can connect to any xmpp/jabber c2s endpoint.
As far as JAXL sample example goes, here are a few that you can directly use: https://github.com/abhinavsingh/JAXL/tree/master/app Look specifically at boshchat.php, boshMUCchat.php and preFetchBOSH.php examples which demonstrate the BOSH side support of Jaxl library.
These examples can be used if you are expecting moderate traffic. For a heavy traffic based application i would seriously recommend using a strophe.js based solution.
BOSH is a technology for sending messages from a server to a client over HTTP. It was developed for use with XMPP/Jabber as a way to emulate TCP, but could be used by other technologies. Essentially BOSH is just the most used carrier of XMPP messages.
This question might help you more, in relation to actual implementation.
What is the current state of Push technology in web development? I heard solutions like Comet as described in this article are not used anymore and instead WebSocket is the future for this kind of features, but it's only supported in Chrome and Safari.
What is the best technique to use?
I'm developing a game where many players (between 2 and 4) can seamlessly interact with each others. I'm using PHP server side and Jquery in client side.
There is a solution that will work in older browsers. I don't know the finer details but I'm sure liking the blurb: (see query-graceful-websocket)
The Graceful WebSocket
So, you want to start building realtime event driven applications using the new HTML5 WebSocket API?
You want it to work in all browsers, no matter if they have WebSocket support or not
You don't want to rely on proprietary technology such as Flash to provide a fallback
And naturally, you don't want to write more than one implementation
Introducing, the gracefulWebSocket jQuery plugin:
Implements the w3c WebSocket interface
Wraps the native WebSocket if support is detected
Provides a default fallback using traditional AJAX polling over HTTP
Requires no extra code on the frontend, allows you to target the WebSocket API today and let users take advantage of it as more browsers add support.
Default fallback behavior can be overridden by plugin options
https://github.com/ffdead/jquery-graceful-websocket
I use beaconpush (Software as a Service) easy to implement, nice API, interesting functions - definitely worth a look.
I'm choosing between AMQP (RabbitMQ) vs XMPP (eJabberd) for my browser-based flash-free javascript powered real-time turn-based game. I don't know much about AMQP and XMPP protocol. I would like to use PHP for user-authorization and some data store-retrieve with MySQL. As far as I found out, RabbitMQ has PHP clients but eJabberd not.
What I understood is javascript client calls PHP script and manipulate necessary processing and then pass to AMQP or XMPP server to pass the data to opponent player. There is a good book 'Pro XMPP Programming with JS and jQuery' from Wrox but there is no example with PHP. So following are my questions.
1) Which protocol is suit for my game?
2) Shall I choose RabbitMQ just for it's PHP client support?
I've had fairly good success implementing an XMPP client in Javascript by using HTTP Bind approach to XMPP BOSH. I don't know about AMQP, but for client-side access, I love XMPP. A few words why.
ejabberd already includes BOSH support, and to use with Javascript (and presumably Flash) you just need to direct your server to redirect requests to port on which you configure ejabberd to listen for HTTP requests. (And even this only because Javascript security model in today's browsers forbids Javascript requests to different domains and even different ports.)
Since XMPP is a bunch of quite trivial small XML documents, it should be fairly easy to encode them in any language you pick.
Since it's widely supported, you might be able to avoid requiring your users to register with your service, which they will most certainly appreciate.
Implementing XMPP means you can trivially add instant messaging support to your game, with federationing to the rest of the Jabber network (including Google Talk).
Since I don't know anything about AMQP, I cannot compare them -- but I can say why I'll always first consider XMPP for my future multiplayer projects.
My personal reason for choosing ejabberd is simple -- it's super easy to install and configure on Debian. I'm almost completely unfamiliar with Erlang and Java; what I understand, however, about Erlang is that it makes scalability easy to achieve, and ejabberd people say they have achieved it.
If you want to do server side logic checking, I'm afraid I don't know of any good method. I'd go with a proxy PHP script doing sanity checking on the incoming XMPP BOSH message, then forwarding it to the server, instead of just forwarding it via Apache's mod_rewrite.
As mentioned above, you will definitely have to do proxying of some sort (with mod_rewrite or with PHP or in some other way) since the XMPP server will listen on a different port than the "main" web server, and Javascript cross-domain security model does not allow doing XMLHTTPRequest on a different port.
So, sanity checking might be easiest done while relaying BOSH requests to XMPP server of your choice. Digging into the server software might not be the best way to do this type of checks. It would take long, and would probably make it harder to integrate with the rest of your game.
Alternatively, I stumbled upon an answer that mentions XMPP components and ejabberd modules. This will be an interesting read for me, too.
Good luck, and be sure to drop a comment with the name of the game when it's done -- I'd love to see it :-)
I just noticed someone else posted a very similar question to yours. Its answers contain some more interesting info for you.
On using XMPP with Flash:
You could nevertheless use HTTP binding (BOSH) with Flash. In fact, while HTTP binding allows Javascript to access XMPP, it was conceived for a variety of applications, such as mobile connections that can often break.
I mostly figured out how to establish the connection by observing communications between web-based client JWChat and ejabberd (for info on BOSH), and then communications between cross-platform client Psi and ejabberd (for info on protocol itself). With JWChat and WebKit's Web Inspector or with Firebug for Firefox, one can easily track XMLHttpRequests being done towards the server. With Psi, one can turn on the XML console and read the communications log. Combined with prototyping a client in a language of your choice, studying BOSH and XMPP turned out to be very easy.
Also, following XEPs are useful: XEP-0124, XEP-0206.
O'Reilly book that I'm reading right now, "XMPP: The Definitive Guide" (P. Saint-Andre, Kevin Smith, Remko Tronçon; much cheaper on Apple's App Store) also gives you the feeling "why things are done the way they are", and documents many small things and various applications of XMPP.
After that, implementing a BOSH-based client could turn out to be rather easy. I have no experience with coding with Flash apart from making a button play and pause, so take this with a grain of salt :-)
As someone mentioned, you need to consider the client-to-server part; that seems of more importance.
It sounds like you already have the best book on the subject (Jack Moffit's XMPP + JS book) and I would definitely say that's the technology to go with.
Also you get user authentication, encryption and all the many XMPP protocol extensions on top of that, as the book will describe.
Even although I can't recommend any PHP-XMPP clients, I don't think you'd necessarily have the same level of features out-of-the-box with AMQP.
Also, if you're versed in other languages, and depending on the amount of game logic required, you could write an XMPP server component. See this prior question about XMPP + gaming for info:
XMPP C# Interaction
AMQP has not yet reached version 1.0 and has some possible design issues around it. There are XMPP clients for PHP so if I were you I'd give that a try first.