SlideShare uma empresa Scribd logo
1 de 20
WebSockets && SockJS
Ahmedur Rahman Shovon
Codalo
shovon.codalo@gmail.com
Different Communication Techniques in Web
●AJAX: request → response. Creates connection to server, sends request headers
with optional data, gets response from server, closes connection.
●Long poll: request → wait → response. Creates connection to server like AJAX
does, but keep-alive connection open for some time (not long though).
●WebSockets: client ↔ server. Create TCP connection to server, and keep it as
long as needed. Server or client can easily close it.
What is WebSockets?
“WebSockets is a
technology for
bidirectional
communication over
single (TCP) socket, a
type of PUSH
technology.”
From code.tutsplus.com
Client-Server Communication
Events
Advantages
● Cross origin communication
(however this poses security risks)
● Cross platform compatibility (web,
desktop, mobile)
● No HTTP overhead
● Replace long-polling
● WebSockets are data typed but AJAX
calls can only send String datatypes
● WebSockets are faster than AJAX
● WebSockets has no success functions
like AJAX
● WebSockets needs server support.
Though any server will support
WebSockets. Using hosting service,
one may not be able to use them,
specially Heroku.
● Load testing
● Scaling, redundancy, load balancing,
replication
Disadvantages
● Multiplayer online games
● Chat applications
● Live sports ticker
● Real time updating social streams
Use Cases of WebSockets
● SockJS is a browser JavaScript library that provides a WebSocket-
like object.
● It gives a coherent, cross-browser, Javascript API which creates a
low latency, full duplex, cross-domain communication channel
between the browser and the web server.
● Under the hood SockJS tries to use native WebSockets first.
● SockJS is intended to work for all modern browsers and in
environments which don't support the WebSocket protocol.
What is SockJS?
SockJS-client, SockJS-server
SockJS-client JavaScript client library
SockJS-node Node.js server
SockJS-erlang Erlang server
SockJS-cyclone Python/Cyclone/Twisted server
SockJS-tornado Python/Tornado server
SockJS-twisted Python/Twisted server
Spring Framework Java client & server
vert.x Java/vert.x server
Xitrum Scala server
Atmosphere Framework JavaEE Server, Play Framework, Netty, Vert.x
Remember these things please
What should I do to play with SockJS?
Required Setup to Wear Socks!
● SockJS client side library: sockjs-1.1.1.min.js
● Node.js (for running SockJS server, you can choose others too)
● SockJS libraries based on the SockJS server
● Node.js server library recommended by the SockJS: SockJS-node
● SockJS-node is a Node.js server side counterpart of SockJS-client browser library
written in CoffeeScript.
● SockJS-node Installation: npm install sockjs
Now let’s see socketing in action!
Installing SockJS Server
At first we need to install SockJS-node as we are using Node.js as SockJS server.
● First install the Node.js installer.
● Then using Node Package Manager(NPM) install SockJS-node.
Installing SockJS-node using npm
SockJS Server
Server Script
Running the server
SockJS Client Application
Client Side Application
chat_client.js
SockJS Client Demo
User 1 User 2
And it’s open source!
● SockJS-Client: https://github.com/sockjs/sockjs-client
● SockJS-Node: https://github.com/sockjs/sockjs-node
● Did not like the demo interface? Have a look at updated code here:
https://github.com/arsho/real_time_chatting_wearing_socks
Note Behind
This interface does not allow for raw access to the
underlying network. For example, this interface could
not be used to implement an IRC client without
proxying messages through a custom server.
Browser Quirks
● Pressing ESC in Firefox, before Firefox 20, closes the SockJS connection.
● jsonp-polling transport will show a "spinning wheel" (aka. "busy indicator") when
sending data.
● Can't open more than one SockJS connection to one domain at the same time.
● From SockJS' point of view there is nothing special about SSL/HTTPS.
● Trying to connect from secure "https://" to insecure "http://" is not a good idea.
Thank you.

Mais conteúdo relacionado

Mais procurados (20)

Database systems introduction
Database systems introductionDatabase systems introduction
Database systems introduction
 
Unix features, posix and single unix specification
Unix features, posix and single unix specificationUnix features, posix and single unix specification
Unix features, posix and single unix specification
 
Arrays in Java
Arrays in JavaArrays in Java
Arrays in Java
 
Data Models
Data ModelsData Models
Data Models
 
Relational Database Management System
Relational Database Management SystemRelational Database Management System
Relational Database Management System
 
Mysql joins
Mysql joinsMysql joins
Mysql joins
 
Java Class Loading
Java Class LoadingJava Class Loading
Java Class Loading
 
Introduction to Java -unit-1
Introduction to Java -unit-1Introduction to Java -unit-1
Introduction to Java -unit-1
 
Basic DBMS ppt
Basic DBMS pptBasic DBMS ppt
Basic DBMS ppt
 
MALWARE AND ITS TYPES
MALWARE AND ITS TYPESMALWARE AND ITS TYPES
MALWARE AND ITS TYPES
 
MYSQL.ppt
MYSQL.pptMYSQL.ppt
MYSQL.ppt
 
Storage Structure in OS
Storage Structure in OSStorage Structure in OS
Storage Structure in OS
 
Scanner class
Scanner classScanner class
Scanner class
 
Ppt on this and super keyword
Ppt on this and super keywordPpt on this and super keyword
Ppt on this and super keyword
 
MySQL and its basic commands
MySQL and its basic commandsMySQL and its basic commands
MySQL and its basic commands
 
Characteristic of dabase approach
Characteristic of dabase approachCharacteristic of dabase approach
Characteristic of dabase approach
 
Hacking Kishor
Hacking KishorHacking Kishor
Hacking Kishor
 
operating system
operating systemoperating system
operating system
 
Abstraction java
Abstraction javaAbstraction java
Abstraction java
 
Short notes of oop with java
Short notes of oop with javaShort notes of oop with java
Short notes of oop with java
 

Destaque

SockJS Intro
SockJS IntroSockJS Intro
SockJS IntroNgoc Dao
 
Spring + WebSocket integration
Spring + WebSocket integrationSpring + WebSocket integration
Spring + WebSocket integrationOleksandr Semenov
 
Spring Boot & WebSocket
Spring Boot & WebSocketSpring Boot & WebSocket
Spring Boot & WebSocketMing-Ying Wu
 
Sometimes web sockets_dont_work
Sometimes web sockets_dont_workSometimes web sockets_dont_work
Sometimes web sockets_dont_workXMPPUK
 
Blending django, Sockjs, Twisted, Celery, FTP and some magic sauce into a bla...
Blending django, Sockjs, Twisted, Celery, FTP and some magic sauce into a bla...Blending django, Sockjs, Twisted, Celery, FTP and some magic sauce into a bla...
Blending django, Sockjs, Twisted, Celery, FTP and some magic sauce into a bla...frog32
 
BASH SPOT Work Sample.compressed
BASH SPOT Work Sample.compressedBASH SPOT Work Sample.compressed
BASH SPOT Work Sample.compressedJhana Jones
 
Madame Bovary
Madame BovaryMadame Bovary
Madame BovaryMarseglia
 
Pataphysique
PataphysiquePataphysique
PataphysiqueMarseglia
 
sujitResume (76)
sujitResume (76)sujitResume (76)
sujitResume (76)S phutane
 
Semiología de la expresión gráfica infantil. Estudio de caso.
Semiología de la expresión gráfica infantil. Estudio de caso.Semiología de la expresión gráfica infantil. Estudio de caso.
Semiología de la expresión gráfica infantil. Estudio de caso.samsuacop
 
"And bob's your uncle." - Navigating the sea of Cloud offerings to business o...
"And bob's your uncle." - Navigating the sea of Cloud offerings to business o..."And bob's your uncle." - Navigating the sea of Cloud offerings to business o...
"And bob's your uncle." - Navigating the sea of Cloud offerings to business o...Michel Drescher
 
Japan drama, novel, short stories
Japan drama, novel, short storiesJapan drama, novel, short stories
Japan drama, novel, short storiesJerine Aina Lugami
 
Using SockJS(Websocket) with Sencha Ext JS
Using SockJS(Websocket) with Sencha Ext JSUsing SockJS(Websocket) with Sencha Ext JS
Using SockJS(Websocket) with Sencha Ext JSKazuhiro Kotsutsumi
 

Destaque (19)

SockJS Intro
SockJS IntroSockJS Intro
SockJS Intro
 
WebSockets with Spring 4
WebSockets with Spring 4WebSockets with Spring 4
WebSockets with Spring 4
 
Spring + WebSocket integration
Spring + WebSocket integrationSpring + WebSocket integration
Spring + WebSocket integration
 
Spring Boot & WebSocket
Spring Boot & WebSocketSpring Boot & WebSocket
Spring Boot & WebSocket
 
Sometimes web sockets_dont_work
Sometimes web sockets_dont_workSometimes web sockets_dont_work
Sometimes web sockets_dont_work
 
Blending django, Sockjs, Twisted, Celery, FTP and some magic sauce into a bla...
Blending django, Sockjs, Twisted, Celery, FTP and some magic sauce into a bla...Blending django, Sockjs, Twisted, Celery, FTP and some magic sauce into a bla...
Blending django, Sockjs, Twisted, Celery, FTP and some magic sauce into a bla...
 
BASH SPOT Work Sample.compressed
BASH SPOT Work Sample.compressedBASH SPOT Work Sample.compressed
BASH SPOT Work Sample.compressed
 
Madame Bovary
Madame BovaryMadame Bovary
Madame Bovary
 
Pataphysique
PataphysiquePataphysique
Pataphysique
 
Bajina basta6 a
Bajina basta6 aBajina basta6 a
Bajina basta6 a
 
sujitResume (76)
sujitResume (76)sujitResume (76)
sujitResume (76)
 
Message Broker System and RabbitMQ
Message Broker System and RabbitMQMessage Broker System and RabbitMQ
Message Broker System and RabbitMQ
 
Semiología de la expresión gráfica infantil. Estudio de caso.
Semiología de la expresión gráfica infantil. Estudio de caso.Semiología de la expresión gráfica infantil. Estudio de caso.
Semiología de la expresión gráfica infantil. Estudio de caso.
 
"And bob's your uncle." - Navigating the sea of Cloud offerings to business o...
"And bob's your uncle." - Navigating the sea of Cloud offerings to business o..."And bob's your uncle." - Navigating the sea of Cloud offerings to business o...
"And bob's your uncle." - Navigating the sea of Cloud offerings to business o...
 
Mani Final Resume
Mani Final ResumeMani Final Resume
Mani Final Resume
 
Japan drama, novel, short stories
Japan drama, novel, short storiesJapan drama, novel, short stories
Japan drama, novel, short stories
 
WebSockets and Java
WebSockets and JavaWebSockets and Java
WebSockets and Java
 
Using SockJS(Websocket) with Sencha Ext JS
Using SockJS(Websocket) with Sencha Ext JSUsing SockJS(Websocket) with Sencha Ext JS
Using SockJS(Websocket) with Sencha Ext JS
 
Formation1 sockets
Formation1 socketsFormation1 sockets
Formation1 sockets
 

Semelhante a Websockets and SockJS, Real time chatting

Nodejs and WebSockets
Nodejs and WebSocketsNodejs and WebSockets
Nodejs and WebSocketsGonzalo Ayuso
 
Real time web_apps_pycon2012-v1
Real time web_apps_pycon2012-v1Real time web_apps_pycon2012-v1
Real time web_apps_pycon2012-v1Avinash Prasad
 
Introduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.comIntroduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.comVan-Duyet Le
 
WebSockets Everywhere: the Future Transport Protocol for Everything (Almost)
WebSockets Everywhere: the Future Transport Protocol for Everything (Almost)WebSockets Everywhere: the Future Transport Protocol for Everything (Almost)
WebSockets Everywhere: the Future Transport Protocol for Everything (Almost)Ericom Software
 
Building Next Generation Real-Time Web Applications using Websockets
Building Next Generation Real-Time Web Applications using WebsocketsBuilding Next Generation Real-Time Web Applications using Websockets
Building Next Generation Real-Time Web Applications using WebsocketsNaresh Chintalcheru
 
Kalp Corporate Node JS Perfect Guide
Kalp Corporate Node JS Perfect GuideKalp Corporate Node JS Perfect Guide
Kalp Corporate Node JS Perfect GuideKalp Corporate
 
JavaScript is the new black - Why Node.js is going to rock your world - Web 2...
JavaScript is the new black - Why Node.js is going to rock your world - Web 2...JavaScript is the new black - Why Node.js is going to rock your world - Web 2...
JavaScript is the new black - Why Node.js is going to rock your world - Web 2...Tom Croucher
 
Real-Time with Flowdock
Real-Time with FlowdockReal-Time with Flowdock
Real-Time with FlowdockFlowdock
 
Java networking programs - theory
Java networking programs - theoryJava networking programs - theory
Java networking programs - theoryMukesh Tekwani
 
Practical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.jsPractical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.jsasync_io
 
Developing realtime apps with Drupal and NodeJS
Developing realtime apps with Drupal and NodeJS Developing realtime apps with Drupal and NodeJS
Developing realtime apps with Drupal and NodeJS drupalcampest
 
GWT Web Socket and data serialization
GWT Web Socket and data serializationGWT Web Socket and data serialization
GWT Web Socket and data serializationGWTcon
 
Node.js: The What, The How and The When
Node.js: The What, The How and The WhenNode.js: The What, The How and The When
Node.js: The What, The How and The WhenFITC
 
GeekCampSG - Nodejs , Websockets and Realtime Web
GeekCampSG - Nodejs , Websockets and Realtime WebGeekCampSG - Nodejs , Websockets and Realtime Web
GeekCampSG - Nodejs , Websockets and Realtime WebBhagaban Behera
 

Semelhante a Websockets and SockJS, Real time chatting (20)

Nodejs and WebSockets
Nodejs and WebSocketsNodejs and WebSockets
Nodejs and WebSockets
 
Node.js Introduction
Node.js IntroductionNode.js Introduction
Node.js Introduction
 
Real time web_apps_pycon2012-v1
Real time web_apps_pycon2012-v1Real time web_apps_pycon2012-v1
Real time web_apps_pycon2012-v1
 
Introduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.comIntroduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.com
 
Node J pdf.docx
Node J pdf.docxNode J pdf.docx
Node J pdf.docx
 
Node J pdf.docx
Node J pdf.docxNode J pdf.docx
Node J pdf.docx
 
Node
NodeNode
Node
 
WebSockets Everywhere: the Future Transport Protocol for Everything (Almost)
WebSockets Everywhere: the Future Transport Protocol for Everything (Almost)WebSockets Everywhere: the Future Transport Protocol for Everything (Almost)
WebSockets Everywhere: the Future Transport Protocol for Everything (Almost)
 
Building Next Generation Real-Time Web Applications using Websockets
Building Next Generation Real-Time Web Applications using WebsocketsBuilding Next Generation Real-Time Web Applications using Websockets
Building Next Generation Real-Time Web Applications using Websockets
 
Kalp Corporate Node JS Perfect Guide
Kalp Corporate Node JS Perfect GuideKalp Corporate Node JS Perfect Guide
Kalp Corporate Node JS Perfect Guide
 
Web-Socket
Web-SocketWeb-Socket
Web-Socket
 
JavaScript is the new black - Why Node.js is going to rock your world - Web 2...
JavaScript is the new black - Why Node.js is going to rock your world - Web 2...JavaScript is the new black - Why Node.js is going to rock your world - Web 2...
JavaScript is the new black - Why Node.js is going to rock your world - Web 2...
 
Real-Time with Flowdock
Real-Time with FlowdockReal-Time with Flowdock
Real-Time with Flowdock
 
Java networking programs - theory
Java networking programs - theoryJava networking programs - theory
Java networking programs - theory
 
Practical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.jsPractical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.js
 
Developing realtime apps with Drupal and NodeJS
Developing realtime apps with Drupal and NodeJS Developing realtime apps with Drupal and NodeJS
Developing realtime apps with Drupal and NodeJS
 
GWT Web Socket and data serialization
GWT Web Socket and data serializationGWT Web Socket and data serialization
GWT Web Socket and data serialization
 
Node.js: The What, The How and The When
Node.js: The What, The How and The WhenNode.js: The What, The How and The When
Node.js: The What, The How and The When
 
Node.js on Azure
Node.js on AzureNode.js on Azure
Node.js on Azure
 
GeekCampSG - Nodejs , Websockets and Realtime Web
GeekCampSG - Nodejs , Websockets and Realtime WebGeekCampSG - Nodejs , Websockets and Realtime Web
GeekCampSG - Nodejs , Websockets and Realtime Web
 

Último

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 

Último (20)

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 

Websockets and SockJS, Real time chatting

  • 1. WebSockets && SockJS Ahmedur Rahman Shovon Codalo shovon.codalo@gmail.com
  • 2. Different Communication Techniques in Web ●AJAX: request → response. Creates connection to server, sends request headers with optional data, gets response from server, closes connection. ●Long poll: request → wait → response. Creates connection to server like AJAX does, but keep-alive connection open for some time (not long though). ●WebSockets: client ↔ server. Create TCP connection to server, and keep it as long as needed. Server or client can easily close it.
  • 4. “WebSockets is a technology for bidirectional communication over single (TCP) socket, a type of PUSH technology.” From code.tutsplus.com
  • 6. Advantages ● Cross origin communication (however this poses security risks) ● Cross platform compatibility (web, desktop, mobile) ● No HTTP overhead ● Replace long-polling ● WebSockets are data typed but AJAX calls can only send String datatypes ● WebSockets are faster than AJAX ● WebSockets has no success functions like AJAX ● WebSockets needs server support. Though any server will support WebSockets. Using hosting service, one may not be able to use them, specially Heroku. ● Load testing ● Scaling, redundancy, load balancing, replication Disadvantages
  • 7. ● Multiplayer online games ● Chat applications ● Live sports ticker ● Real time updating social streams Use Cases of WebSockets
  • 8. ● SockJS is a browser JavaScript library that provides a WebSocket- like object. ● It gives a coherent, cross-browser, Javascript API which creates a low latency, full duplex, cross-domain communication channel between the browser and the web server. ● Under the hood SockJS tries to use native WebSockets first. ● SockJS is intended to work for all modern browsers and in environments which don't support the WebSocket protocol. What is SockJS?
  • 9. SockJS-client, SockJS-server SockJS-client JavaScript client library SockJS-node Node.js server SockJS-erlang Erlang server SockJS-cyclone Python/Cyclone/Twisted server SockJS-tornado Python/Tornado server SockJS-twisted Python/Twisted server Spring Framework Java client & server vert.x Java/vert.x server Xitrum Scala server Atmosphere Framework JavaEE Server, Play Framework, Netty, Vert.x Remember these things please
  • 10. What should I do to play with SockJS?
  • 11. Required Setup to Wear Socks! ● SockJS client side library: sockjs-1.1.1.min.js ● Node.js (for running SockJS server, you can choose others too) ● SockJS libraries based on the SockJS server ● Node.js server library recommended by the SockJS: SockJS-node ● SockJS-node is a Node.js server side counterpart of SockJS-client browser library written in CoffeeScript. ● SockJS-node Installation: npm install sockjs
  • 12. Now let’s see socketing in action!
  • 13. Installing SockJS Server At first we need to install SockJS-node as we are using Node.js as SockJS server. ● First install the Node.js installer. ● Then using Node Package Manager(NPM) install SockJS-node. Installing SockJS-node using npm
  • 15. SockJS Client Application Client Side Application chat_client.js
  • 17. And it’s open source! ● SockJS-Client: https://github.com/sockjs/sockjs-client ● SockJS-Node: https://github.com/sockjs/sockjs-node ● Did not like the demo interface? Have a look at updated code here: https://github.com/arsho/real_time_chatting_wearing_socks
  • 18. Note Behind This interface does not allow for raw access to the underlying network. For example, this interface could not be used to implement an IRC client without proxying messages through a custom server.
  • 19. Browser Quirks ● Pressing ESC in Firefox, before Firefox 20, closes the SockJS connection. ● jsonp-polling transport will show a "spinning wheel" (aka. "busy indicator") when sending data. ● Can't open more than one SockJS connection to one domain at the same time. ● From SockJS' point of view there is nothing special about SSL/HTTPS. ● Trying to connect from secure "https://" to insecure "http://" is not a good idea.