SlideShare a Scribd company logo
AD102 - Bring WebSocket Technology to Your Next
XPage Application
Csaba Kiss 08/19/2016
LA-UR-16-20047
Credentials
Over 25 years experience in molecular biology
Began XPage application development in 2014
JavaScript enthusiast
Twitter: @csakis
Blog: XpageXplorer.org
MWLUG survey
mwlug2016.mybluemix.net
Agenda
HTTP protocol drawbacks
Websocket
– Why does it exist? (Background)
– How do you use it? (API)
– How do you get it work? (Installation)
– WebSocket code examples
– Server side listeners using SSJS
– Pros and cons
DEMO DEMO DEMO
HTTP protocol
The Hypertext Transfer Protocol (HTTP) is an application protocol for distributed,
collaborative, hypermedia information systems. HTTP functions as a request-response
protocol in the client-server computing model.*
*: wikipedia
Client Server
Request
Request
Response
Response
Response
Too much overhead
871 bytes header data (without any session/cookie data)
Clients Req/min* MB/min
100 600 5
500 30,000 26
1,000 60,000 52
10,000 600,000 522
*: 1 request every second
Other HTTP limitations
Every request needs a new connection (latency)
Half duplex connection (walkie talkie)
Work arounds
Long-polling (comet)
Complicated implementation, Not standardized.
Client
Server
Request
Request
Response
Response
The creation of WebSocket
WebSocket is a protocol providing full-duplex communication channels over a single
TCP connection.
Both the WebSocket API itself (W3C) and the WebSocket protocol are HTML5
standards.
The WebSocket protocol is supported in the latest versions of browsers
Client Server
Message
Message
Message
Message
Message
Message
Browser compatibility*
*:caniuse.com
MWLUG 2016
Websocket API
Websocket constructor
Establishing a new websocket connection
1 2 3 4
1. ws is the new websocket object
2. ws:// denotes websocket protocol
3. WebSocket port
4. optional protocols
The hand shake
The client sends a WebSocket handshake request:
The server responds:
Connection is “upgraded”
WebSocket is purely event driven
4 events
WebSocket methods
2 methods
The websocket message format is important with the OpenNTF websocket plugin.
Optional close codes:
1000 – CLOSE_NORMAL
1006 – CLOSE_ABNORMAL
1012 – SERVICE_RESTART
…
Simple websocket message format
Message in JSON format
Sender format needs to be in a canonical format: @UserName()
Recipient:
– broadcast (everybody receives it)
– to: single user (canonical user name)
– targets: [‘user1’, ‘user2’, …]
– URI based: /mwlug2016.nsf/home.xsp*
– Role based targeting
Date: omitted || Unix epoch || yyyy-MM-dd hh:mm
Complex WebSocket message
Embedded data object
Binary data transfer
Sending other attributes
– Application
– Message type
…
WebSocket server is not
application specific!!
WebSocket attributes
readyState
CONNECTING
OPEN
CLOSING
CLOSED
bufferedAmount
returns the number of bytes
that have been queued but
not yet sent.
Useful to prevent network
saturation
WebSocket server side listener
• Very convenient to communicate with the underlying Domino Db
• Adds an extra WebSocket user that sits and listens on the server side
• Gives you an alternative way of submitting data or querying the database
• Server side listener uses Rhino JavaScript Engine
– No access to scope variables or @functions
– Cannot define variables with : notation
• i.e. var doc:NotesDocument = currentDocument.getDocument();
• Initialization:
ServerSide tips
websocket message = socketMessage
sender = socketMessage.getFrom();
websocket text message = socketMessage.getText();
Getting Data attribute example:
var application = socketMessage.getData().get("application");
WebSocket debugging in Chrome
Use Chrome!!
New!! WebSocket debugging in Firefox 48
WebSocket monitor extension
Potential applications
If you build multi-user applications in which users
interact with each other and the underlying
database; and data is updated regularly in the
webapp, you should use WebSocket technology.
Watson IoT HQ in Munich
Potential problems and pitfalls
Proxies and firewalls:
– Long-lived connections might not be allowed
– Designed for HTTP traffic
– Might filter out other traffic
(use Secure connection wss://…)
Scaling presents a different challenge:
– Many free ports are needed on your server
OpenNTF xockets.io extension*
https://www.openntf.org/main.nsf/project.xsp?r=project/xockets.io/
GitHub:
https://github.com/mwambler/xockets.io
Domino Implementation of Java-WebSocket server http://java-websocket.org
Support
Mark Ambler
Tek Counsel LLC
Twitter: @mwambler
Blog: http://markwambler.blogspot.com
Email:mambler@tekcounsel.net
*: IBM Domino server does not support WebSocket protocol
Xockets.io installation on Domino server
Detailed instructions:
http://xpagexplorer.org/websocket-install/
3-part blog post series
Test Domino websocket extension
Use included chat.nsf application to test if WebSocket connection can be established
DEMO
Lucky widget code example
• On page load, we need to get the latest styles from the DB
• On button click, we need to generate the styles and send the websocket message
• Client side: On Message received: apply the style to the page element
• Server Side: On Message received: update the DB with the latest style
Client side initialization
XPage
application.js
Tip: Use the chat.nsf example database
that comes with the xocket.io plugin.
luckyWidget/sending msg
Xpage code
Button event listener
Create message header
Create shape message
luckyWidget/receiving msg
Client side websocket handling
luckyWidget/socketListener
beforePageLoad event
applicationSSJS
luckyWidget/SSJS
beforePageLoad event luckyDiv calculated style
Websocket conclusion
Allows you combine http protocol with websocket data traffic.
Lets developers write event-driven real-time applications.
Helps you writing single page Xpage applications with no partial refreshes.
User experience is more fluid and satisfying.
The OpenNTF xocket.io library allows developers to write native XPage applications
with seamless server side Domino database integration.
Contact
Twitter: @csakis
Blog: http://XpageXplorer.org
Thank you for your attention!

More Related Content

What's hot (20)

PPS
Squid
Chirag Gupta
 
PPTX
MuleSoft ESB Sending email using hmailserver
akashdprajapati
 
PDF
Introduction to FreeNAS development by John Hixson
iXsystems
 
PDF
Cc proxy
Trường Tiền
 
PPTX
Creating a Domain with Oracle WebLogic 11g
Luis Carlos Berrocal
 
PDF
Web Communication
Adrian Olaru
 
PDF
Nelf2012
Dru Lavigne
 
PDF
Introduction to Penetration Testing
UTD Computer Security Group
 
PDF
Introducing with MongoDB
Mahbub Tito
 
PPT
论文答辩
wensheng wei
 
DOCX
Project on squid proxy in rhel 6
Nutan Kumar Panda
 
PDF
Scale13
Dru Lavigne
 
PDF
Webmin configuration in Linux
Thamizharasan P
 
ODP
Squid Proxy Server
13bcs0012
 
PDF
Docker rant
gnosek
 
PDF
Ce hv6 module 54 proxy server technologies
Vi Tính Hoàng Nam
 
KEY
Router と WebSocket
Kensaku Komatsu
 
PDF
Fosscon2013
Dru Lavigne
 
PPT
Squid server
Rohit Phulsunge
 
PDF
Squid proxy server
Green Jb
 
MuleSoft ESB Sending email using hmailserver
akashdprajapati
 
Introduction to FreeNAS development by John Hixson
iXsystems
 
Creating a Domain with Oracle WebLogic 11g
Luis Carlos Berrocal
 
Web Communication
Adrian Olaru
 
Nelf2012
Dru Lavigne
 
Introduction to Penetration Testing
UTD Computer Security Group
 
Introducing with MongoDB
Mahbub Tito
 
论文答辩
wensheng wei
 
Project on squid proxy in rhel 6
Nutan Kumar Panda
 
Scale13
Dru Lavigne
 
Webmin configuration in Linux
Thamizharasan P
 
Squid Proxy Server
13bcs0012
 
Docker rant
gnosek
 
Ce hv6 module 54 proxy server technologies
Vi Tính Hoàng Nam
 
Router と WebSocket
Kensaku Komatsu
 
Fosscon2013
Dru Lavigne
 
Squid server
Rohit Phulsunge
 
Squid proxy server
Green Jb
 

Viewers also liked (7)

PDF
Diseño de intercamiedores
Elier Diaz
 
PPTX
Saleforce For Domino Dogs
Mark Myers
 
PDF
Hacking (with) WebSockets
Sergey Shekyan
 
PDF
Hacking websockets
Tomek Cejner
 
PPTX
2016 SUTOL - Salesforce App Cloud and Domino - same same, but different
René Winkelmeyer
 
PDF
Find your data
Oliver Busse
 
PPTX
OpenNTF 2015 Edition
Christian Güdemann
 
Diseño de intercamiedores
Elier Diaz
 
Saleforce For Domino Dogs
Mark Myers
 
Hacking (with) WebSockets
Sergey Shekyan
 
Hacking websockets
Tomek Cejner
 
2016 SUTOL - Salesforce App Cloud and Domino - same same, but different
René Winkelmeyer
 
Find your data
Oliver Busse
 
OpenNTF 2015 Edition
Christian Güdemann
 
Ad

Similar to Websocket technology for XPages (20)

PPT
Web-Socket
Pankaj Kumar Sharma
 
PDF
WebSocket Push Fallback - Transcript.pdf
ShaiAlmog1
 
PDF
Building Next Generation Real-Time Web Applications using Websockets
Naresh Chintalcheru
 
PPTX
ClientServer Websocket.pptx
MaxamedSheekhAmiin
 
PDF
Programming WebSockets - OSCON 2010
sullis
 
PPTX
Programming WebSockets with Glassfish and Grizzly
C2B2 Consulting
 
PPTX
WebSockets-Revolutionizing-Real-Time-Communication.pptx
YasserLina
 
PPTX
Html5 websockets
AbhishekMondal42
 
PPT
JUG louvain websockets
Marc Tritschler
 
PDF
WebSockets: The Current State of the Most Valuable HTML5 API for Java Developers
Viktor Gamov
 
PPTX
presentation in .net programming web sockets.pptx
ArvieJayLapig
 
KEY
Pushing the web — WebSockets
Roland M
 
PDF
WebSocket Server - Jul 2010
takanao ENODH
 
PPTX
Intro to Web Sockets
Jim Gourgoutis
 
PPTX
Basic understanding of websocket and and REST API
divyabiru27
 
PDF
WebSocket
njamnjam
 
PDF
WebSocket in Enterprise Applications 2015
Pavel Bucek
 
PPTX
Enhancing Mobile User Experience with WebSocket
Mauricio "Maltron" Leal
 
PPTX
Training Webinar: Enterprise application performance with server push technol...
OutSystems
 
PPTX
Websocket
charmin_pansuriya
 
WebSocket Push Fallback - Transcript.pdf
ShaiAlmog1
 
Building Next Generation Real-Time Web Applications using Websockets
Naresh Chintalcheru
 
ClientServer Websocket.pptx
MaxamedSheekhAmiin
 
Programming WebSockets - OSCON 2010
sullis
 
Programming WebSockets with Glassfish and Grizzly
C2B2 Consulting
 
WebSockets-Revolutionizing-Real-Time-Communication.pptx
YasserLina
 
Html5 websockets
AbhishekMondal42
 
JUG louvain websockets
Marc Tritschler
 
WebSockets: The Current State of the Most Valuable HTML5 API for Java Developers
Viktor Gamov
 
presentation in .net programming web sockets.pptx
ArvieJayLapig
 
Pushing the web — WebSockets
Roland M
 
WebSocket Server - Jul 2010
takanao ENODH
 
Intro to Web Sockets
Jim Gourgoutis
 
Basic understanding of websocket and and REST API
divyabiru27
 
WebSocket
njamnjam
 
WebSocket in Enterprise Applications 2015
Pavel Bucek
 
Enhancing Mobile User Experience with WebSocket
Mauricio "Maltron" Leal
 
Training Webinar: Enterprise application performance with server push technol...
OutSystems
 
Ad

Recently uploaded (20)

PDF
Latest Capcut Pro 5.9.0 Crack Version For PC {Fully 2025
utfefguu
 
PDF
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
PDF
ERP Consulting Services and Solutions by Contetra Pvt Ltd
jayjani123
 
PDF
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
PDF
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
PDF
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
PPTX
iaas vs paas vs saas :choosing your cloud strategy
CloudlayaTechnology
 
PDF
Ready Layer One: Intro to the Model Context Protocol
mmckenna1
 
PDF
intro_to_cpp_namespace_robotics_corner.pdf
MohamedSaied877003
 
PPTX
prodad heroglyph crack 2.0.214.2 Full Free Download
cracked shares
 
PDF
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
PPTX
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
PPTX
Smart Doctor Appointment Booking option in odoo.pptx
AxisTechnolabs
 
PPTX
Get Started with Maestro: Agent, Robot, and Human in Action – Session 5 of 5
klpathrudu
 
PPTX
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
PDF
Why is partnering with a SaaS development company crucial for enterprise succ...
Nextbrain Technologies
 
PDF
Salesforce Experience Cloud Consultant.pdf
VALiNTRY360
 
PDF
Download Canva Pro 2025 PC Crack Full Latest Version
bashirkhan333g
 
PDF
Best Web development company in india 2025
Greenusys
 
PPTX
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
Latest Capcut Pro 5.9.0 Crack Version For PC {Fully 2025
utfefguu
 
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
ERP Consulting Services and Solutions by Contetra Pvt Ltd
jayjani123
 
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
iaas vs paas vs saas :choosing your cloud strategy
CloudlayaTechnology
 
Ready Layer One: Intro to the Model Context Protocol
mmckenna1
 
intro_to_cpp_namespace_robotics_corner.pdf
MohamedSaied877003
 
prodad heroglyph crack 2.0.214.2 Full Free Download
cracked shares
 
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
Smart Doctor Appointment Booking option in odoo.pptx
AxisTechnolabs
 
Get Started with Maestro: Agent, Robot, and Human in Action – Session 5 of 5
klpathrudu
 
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
Why is partnering with a SaaS development company crucial for enterprise succ...
Nextbrain Technologies
 
Salesforce Experience Cloud Consultant.pdf
VALiNTRY360
 
Download Canva Pro 2025 PC Crack Full Latest Version
bashirkhan333g
 
Best Web development company in india 2025
Greenusys
 
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 

Websocket technology for XPages