SlideShare a Scribd company logo
1 of 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.

More Related Content

What's hot

MMO Design Architecture by Andrew
MMO Design Architecture by AndrewMMO Design Architecture by Andrew
MMO Design Architecture by Andrew
Agate Studio
 
이무림, Enum의 Boxing을 어찌할꼬? 편리하고 성능좋게 Enum 사용하기, NDC2019
이무림, Enum의 Boxing을 어찌할꼬? 편리하고 성능좋게 Enum 사용하기, NDC2019이무림, Enum의 Boxing을 어찌할꼬? 편리하고 성능좋게 Enum 사용하기, NDC2019
이무림, Enum의 Boxing을 어찌할꼬? 편리하고 성능좋게 Enum 사용하기, NDC2019
devCAT Studio, NEXON
 

What's hot (20)

MMO Design Architecture by Andrew
MMO Design Architecture by AndrewMMO Design Architecture by Andrew
MMO Design Architecture by Andrew
 
이무림, Enum의 Boxing을 어찌할꼬? 편리하고 성능좋게 Enum 사용하기, NDC2019
이무림, Enum의 Boxing을 어찌할꼬? 편리하고 성능좋게 Enum 사용하기, NDC2019이무림, Enum의 Boxing을 어찌할꼬? 편리하고 성능좋게 Enum 사용하기, NDC2019
이무림, Enum의 Boxing을 어찌할꼬? 편리하고 성능좋게 Enum 사용하기, NDC2019
 
Game script/Character Script
Game script/Character ScriptGame script/Character Script
Game script/Character Script
 
[NDC 2010] 그럴듯한 랜덤 생성 컨텐츠 만들기
[NDC 2010] 그럴듯한 랜덤 생성 컨텐츠 만들기[NDC 2010] 그럴듯한 랜덤 생성 컨텐츠 만들기
[NDC 2010] 그럴듯한 랜덤 생성 컨텐츠 만들기
 
Precomputed Voxelized-Shadows for Large-scale Scene and Many lights
Precomputed Voxelized-Shadows for Large-scale Scene and Many lightsPrecomputed Voxelized-Shadows for Large-scale Scene and Many lights
Precomputed Voxelized-Shadows for Large-scale Scene and Many lights
 
つぶやきGLSLのススメ
つぶやきGLSLのススメつぶやきGLSLのススメ
つぶやきGLSLのススメ
 
Actor Model & Reactive Manifesto
Actor Model & Reactive ManifestoActor Model & Reactive Manifesto
Actor Model & Reactive Manifesto
 
KGC 2016: HTTPS 로 모바일 게임 서버 구축한다는 것 - Korea Games Conference
KGC 2016: HTTPS 로 모바일 게임 서버 구축한다는 것 - Korea Games ConferenceKGC 2016: HTTPS 로 모바일 게임 서버 구축한다는 것 - Korea Games Conference
KGC 2016: HTTPS 로 모바일 게임 서버 구축한다는 것 - Korea Games Conference
 
ConfD で Linux にNetconfを喋らせてみた
ConfD で Linux にNetconfを喋らせてみたConfD で Linux にNetconfを喋らせてみた
ConfD で Linux にNetconfを喋らせてみた
 
Actor Model and C++: what, why and how?
Actor Model and C++: what, why and how?Actor Model and C++: what, why and how?
Actor Model and C++: what, why and how?
 
병렬프로그래밍과 Cuda
병렬프로그래밍과 Cuda병렬프로그래밍과 Cuda
병렬프로그래밍과 Cuda
 
【Unite Tokyo 2019】Unityプログレッシブライトマッパー2019
【Unite Tokyo 2019】Unityプログレッシブライトマッパー2019【Unite Tokyo 2019】Unityプログレッシブライトマッパー2019
【Unite Tokyo 2019】Unityプログレッシブライトマッパー2019
 
Learn nginx in 90mins
Learn nginx in 90minsLearn nginx in 90mins
Learn nginx in 90mins
 
Linux Kernel vs DPDK: HTTP Performance Showdown
Linux Kernel vs DPDK: HTTP Performance ShowdownLinux Kernel vs DPDK: HTTP Performance Showdown
Linux Kernel vs DPDK: HTTP Performance Showdown
 
게임서버프로그래밍 #8 - 성능 평가
게임서버프로그래밍 #8 - 성능 평가게임서버프로그래밍 #8 - 성능 평가
게임서버프로그래밍 #8 - 성능 평가
 
DirectX 11 Rendering in Battlefield 3
DirectX 11 Rendering in Battlefield 3DirectX 11 Rendering in Battlefield 3
DirectX 11 Rendering in Battlefield 3
 
[기획 최정진] 포폴 소개
[기획 최정진] 포폴 소개[기획 최정진] 포폴 소개
[기획 최정진] 포폴 소개
 
게임서버프로그래밍 #4 - 멀티스레드 프로그래밍
게임서버프로그래밍 #4 - 멀티스레드 프로그래밍게임서버프로그래밍 #4 - 멀티스레드 프로그래밍
게임서버프로그래밍 #4 - 멀티스레드 프로그래밍
 
Next generation graphics programming on xbox 360
Next generation graphics programming on xbox 360Next generation graphics programming on xbox 360
Next generation graphics programming on xbox 360
 
Rendering Techniques in Deus Ex: Mankind Divided
Rendering Techniques in Deus Ex: Mankind DividedRendering Techniques in Deus Ex: Mankind Divided
Rendering Techniques in Deus Ex: Mankind Divided
 

Viewers also liked

SockJS Intro
SockJS IntroSockJS Intro
SockJS Intro
Ngoc Dao
 
Spring Boot & WebSocket
Spring Boot & WebSocketSpring Boot & WebSocket
Spring Boot & WebSocket
Ming-Ying Wu
 
BASH SPOT Work Sample.compressed
BASH SPOT Work Sample.compressedBASH SPOT Work Sample.compressed
BASH SPOT Work Sample.compressed
Jhana Jones
 
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
 
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
Kazuhiro Kotsutsumi
 

Viewers also liked (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
 

Similar to Websockets and SockJS, Real time chatting

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
 

Similar to 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
 

Recently uploaded

+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...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Recently uploaded (20)

Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
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
 
+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...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 

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.