Mongooze citizen


Published on

Published in: Technology, News & Politics
1 Like
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Mongooze citizen

  1. 1. MongooseCitizen of the World (Wide Web)
  2. 2. Who are you?Webmaster of social site?Desginer of corporate page?Backend developer?Geek with full stomach after lunch?
  3. 3. How can you embed a chat?Combine PHP, JavaScript and storingmessages in MySQL.Use existing plugin/library and externalchat server.Make custom server with REST/Websocketsinterface.Or...
  4. 4. Host your own chatAll you need is dedicated server whereyou can install Erlang, MongooseIM andopen chosen ports in firewall.May use the server with webpage.Integrate existing JavaScript XMPPlibraries with MongooseIM BOSH andWebsockets endpoints.
  5. 5. Why XMPP?Proven, popular protocolLots of extensionsMany server and client implementationsEasy to comprehend:<message from=””to=””><body>Hello Alice!</body></message>
  6. 6. XEP-0239: Binary XMPP• Traditional stanza: <presence/>• Binary representation:0011110001110000011100100110010101110011011001010110111001100011011001010010111100111110• Binary XMPP representation:<zero/><zero/><one/><one/><one/><one/><zero/><zero/><zero/><one/><one/><one/><zero/><zero/><zero/><zero/><zero/><one/><one/><one/><zero/><zero/><one/><zero/><zero/><one/><one/><zero/><zero/><one/><zero/><one/><zero/><one/><one/><one/><zero/><zero/><one/><one/><zero/><one/><one/><zero/><zero/><one/><zero/><one/><zero/><one/><one/><zero/><one/><one/><one/><zero/><zero/><one/><one/><zero/><zero/><zero/><one/><one/><zero/><one/><one/><zero/><zero/><one/><zero/><one/><zero/><zero/><one/><zero/><one/><one/><one/><one/><zero/><zero/><one/><one/><one/><one/><one/><zero/>
  7. 7. Our little carnivoreVery strong claws todig through lots ofmessagesAble to deal withmultiple meals serversin clusterAdopts very well toEurasian and Africanmodern Web environment.
  8. 8. Getting MongooseDownload package from ESL website or repoClone git repository:
  9. 9. Mongoose’s reflexServer:AMD FX-8150 8x3.3GHz32GB RAMOne big room:3000 users10 messages per secondMultiple rooms:2000 rooms25 users/room0.6 message per second per room
  10. 10. Case Study: Erlang CentralErlang Factory streamsGroupchats for live streams were first.Use MUCkl (with JSJaC as backend)embedded in a very straightforward way(<iframe>).Taps into Wordpress cookies and uses themfor authenticating users.
  11. 11. Client-sideConnects to MongooseIM via WebsocketsAuthenticates with user login andWordpress ‘logged in cookie’Cookie format:piotr_nosek|1368010779|49aa66843380c377e93b198b966eb699user login exp. date magic hash
  12. 12. Steps to create magic hash1. Frag = password_hash[8:11]2. HMACKey = logged_in_key + logged_in_salt3. HMACData = username + Frag + ‘|’ + ExpTime4. HMAC = hmac(md5, HMACData, HMACKey)5. MagicHash = hmac(md5, username + ‘|’ +ExpTime, HMAC)
  13. 13. Server-side moduleejabberd_auth_wordpress.erlReproduces Wordpress ‘logged in cookie’Compares it with provided password(cookie)Generated from user password hashfragment, user login, expiration date andsalt defined by administrator
  14. 14. Facebook-like global groupchatUses xmpptk (with JSJaC backend, likestream chats)Chosen BOSH instead of WebsocketsWebsockets are closed on page reloadTest drive for MongooseIM reimplementedBOSH supportCase Study: Erlang CentralErlang Central Cafe
  15. 15. Client-sideUses cookie generated in similar way to‘logged in cookie’.Modified xmpptk and jQuery chat box tofit into Wordpress plugin and matchErlang Central look and feel.
  16. 16. Server-sideCompares password (cookie) againstgenerated hash.New BOSH implementation.For 3rd party clients: hashes passwordwith Erlang implementation of phpass andchecks against hash stored in DB.
  17. 17. (Side) Effects ofErlang Central chatsReal application for Websockets and new BOSHsupportPeople watching stream have a way of tellingcamera guy to show slides, not just speaker face.:)Modules for integrating Erlang with Wordpressand/or PHP:Cafe pluginphpass implementation
  18. 18. Useful linksMongooseIM load tests - full article auth for MongooseIM:, ‘wordpress’ branchCafe plugin: To Be ReleasedDetailed tutorials (self-advertisement ;))
  19. 19. Thank you!Köszönöm!And see you again in erlang:get_cookie() blog. ;)