This document discusses live streaming and server-sent events for asynchronously sending data from a server to a client. It describes technologies like AJAX polling, Comet, WebSockets, and Server-Sent Events. It provides an example of using Server-Sent Events in a Rails application to stream search results from an asynchronous job to the client in real-time as the data becomes available.
This is my Athcon 2013 slide set. I also demonstrated that attacking mobile applications via SIP Trust, scanning via SIP proxies and MITM fuzzing in Live Demo.
This is my Athcon 2013 slide set. I also demonstrated that attacking mobile applications via SIP Trust, scanning via SIP proxies and MITM fuzzing in Live Demo.
The eduWare student management software provides better bulk data storage of student with easiness. The student information module helps to generate student id-card, various examine reports, student behavior reports etc. User can track record of like student activities, health record, previous school details and exam results etc.
Presentation used by Konstantins Vasilenko giving a talk @ Riga Comm 2017 - Blockchain Conference about how Crypto currencies are being used as Payment method by businesses.
With mandating cloud initiatives, many application services and systems are moving to cloud. In this session, we will learn how Integration Cloud helps us integrate services with cloud based applications without writing any code. Simply connect and configure your integrations right in the graphical browser UI.
View to understand cloud strategy to build integrations and see interesting demo’s on
- Hybrid Integration
- Cloud-to-cloud integration
www.kelltontech.com
It's always been a dilemma -- do you invest in servers, licenses and people to set up and maintain a fully controllable SharePoint infrastructure in-house, or is it time to explore hosting SharePoint off-premise? Legal IT professionals have been struggling with this decision for years.
The on-premise option offers peace of mind from a security and controllability standpoint, but comes saddled with high costs, a demand for resources and limited scalability. SharePoint Online, on the other hand, alleviates the burden associated with SharePoint on-premise by removing the need for servers, software licenses and personnel, and can be rolled out to a large pool of people virtually overnight. However, you'll still need support for integration projects. Join us as we discuss the pros and cons of each option and give you recommendations based on our experiences, deployments and feedback.
Speakers:
Ted Theodoropoulos, as the founder and President of Acrowire, combines his interest in technology with his passion to improve the business productivity of entrepreneurs and corporations. He has a background in technology going back to the early 1980s and is an expert at reducing the cost of doing business by identifying process inefficiencies and implementing the right technology solution to bridge the gap. Ted has earned Six Sigma Green and Black Belt certifications, and his Green Belt work led to a United States patent for which he was recognized with the 2007 Best of Six Sigma Award. He is a Microsoft Certified Professional and a Certified Scrum Master. Contact Ted at ted@acrowire.com.
Brian Gough, a Solutions Architect at Acrowire, offers a wealth of knowledge with over 20 years of experience in the IT industry. He has been working with SharePoint since version 2003, and has set up more than 50 farms and over 200 sites in nine languages. Brian has twice been recognized by Microsoft and his peers as a SharePoint MVP for his contributions to the SharePoint community and knowledge of the product. He has taught classes in SharePoint development and given numerous speeches and presentations around the country on a variety of SharePoint topics. Contact Brian at bgough@acrowire.com.
Domino Server Health - Monitoring and ManagingGabriella Davis
If you're a Domino administrator how do you decide what to monitor on your servers and how to manage them ? What are the key things to monitor? How do good practice management tools such as statistics reporting, DDM, cluster symmetry, database repair and policy settings make your work lighter and faster. Finally we’ll talk about some of the “must dos” in the day, week and month of a Domino admin.
Presented at Engage.ug in Brussels May 2019
Cookies are usually small text files, given ID tags that are stored on your computer's browser directory or program data subfolders. Cookies are created when you use your browser to visit a website that uses cookies to keep track of your movements within the site, help you resume where you left off, remember your registered login, theme selection, preferences, and other customization functions.
Employee Management System (EMS) Project DocumentationMd. Rasel Hossain
This project, developed in the C programming language, serves as the culmination of my studies in the SE-133: Software Development Capstone Project course. Its successful completion holds significant importance as it represents a pivotal component in the attainment of my B.Sc. in Software Engineering at Daffodil International University.
The chat application is used most influential visual philosophies in design. It’s shaping the way people see and interact with interfaces because of clear design and usability guidelines. The complete Firebase Chat Android App source code is built in Android Studio IDE... https://abhiandroid.com/sourcecode/chat
Node.JS is a popular server-side JavaScript framework for handling real-time and distributed data processing. In this session you'll learn what Node.JS is, how it works under the hood, and what scenarios it's useful for. You'll also learn how to deploy it to Windows Azure and manage it inside of IIS 7.
SOAP Web Services have a well established role in the enterprise, but aside from the many benefits of the WS-* standards, SOAP and XML also carry additional baggage for developers. Consequently, REST Web Services are gaining tremendous popularity within the developer community. This session will begin by comparing and contrasting the basic concepts of both SOAP and REST Web Services. Building on that foundation, Sam Brannen will show attendees how to implement SOAP-based applications using Spring-WS 2.0. He will then demonstrate how to build a similar REST-ful application using Spring MVC 3.0. The session will conclude with an in-depth look at both server-side and client-side development as well as efficient integration testing of Web Services using the Spring Framework.
The eduWare student management software provides better bulk data storage of student with easiness. The student information module helps to generate student id-card, various examine reports, student behavior reports etc. User can track record of like student activities, health record, previous school details and exam results etc.
Presentation used by Konstantins Vasilenko giving a talk @ Riga Comm 2017 - Blockchain Conference about how Crypto currencies are being used as Payment method by businesses.
With mandating cloud initiatives, many application services and systems are moving to cloud. In this session, we will learn how Integration Cloud helps us integrate services with cloud based applications without writing any code. Simply connect and configure your integrations right in the graphical browser UI.
View to understand cloud strategy to build integrations and see interesting demo’s on
- Hybrid Integration
- Cloud-to-cloud integration
www.kelltontech.com
It's always been a dilemma -- do you invest in servers, licenses and people to set up and maintain a fully controllable SharePoint infrastructure in-house, or is it time to explore hosting SharePoint off-premise? Legal IT professionals have been struggling with this decision for years.
The on-premise option offers peace of mind from a security and controllability standpoint, but comes saddled with high costs, a demand for resources and limited scalability. SharePoint Online, on the other hand, alleviates the burden associated with SharePoint on-premise by removing the need for servers, software licenses and personnel, and can be rolled out to a large pool of people virtually overnight. However, you'll still need support for integration projects. Join us as we discuss the pros and cons of each option and give you recommendations based on our experiences, deployments and feedback.
Speakers:
Ted Theodoropoulos, as the founder and President of Acrowire, combines his interest in technology with his passion to improve the business productivity of entrepreneurs and corporations. He has a background in technology going back to the early 1980s and is an expert at reducing the cost of doing business by identifying process inefficiencies and implementing the right technology solution to bridge the gap. Ted has earned Six Sigma Green and Black Belt certifications, and his Green Belt work led to a United States patent for which he was recognized with the 2007 Best of Six Sigma Award. He is a Microsoft Certified Professional and a Certified Scrum Master. Contact Ted at ted@acrowire.com.
Brian Gough, a Solutions Architect at Acrowire, offers a wealth of knowledge with over 20 years of experience in the IT industry. He has been working with SharePoint since version 2003, and has set up more than 50 farms and over 200 sites in nine languages. Brian has twice been recognized by Microsoft and his peers as a SharePoint MVP for his contributions to the SharePoint community and knowledge of the product. He has taught classes in SharePoint development and given numerous speeches and presentations around the country on a variety of SharePoint topics. Contact Brian at bgough@acrowire.com.
Domino Server Health - Monitoring and ManagingGabriella Davis
If you're a Domino administrator how do you decide what to monitor on your servers and how to manage them ? What are the key things to monitor? How do good practice management tools such as statistics reporting, DDM, cluster symmetry, database repair and policy settings make your work lighter and faster. Finally we’ll talk about some of the “must dos” in the day, week and month of a Domino admin.
Presented at Engage.ug in Brussels May 2019
Cookies are usually small text files, given ID tags that are stored on your computer's browser directory or program data subfolders. Cookies are created when you use your browser to visit a website that uses cookies to keep track of your movements within the site, help you resume where you left off, remember your registered login, theme selection, preferences, and other customization functions.
Employee Management System (EMS) Project DocumentationMd. Rasel Hossain
This project, developed in the C programming language, serves as the culmination of my studies in the SE-133: Software Development Capstone Project course. Its successful completion holds significant importance as it represents a pivotal component in the attainment of my B.Sc. in Software Engineering at Daffodil International University.
The chat application is used most influential visual philosophies in design. It’s shaping the way people see and interact with interfaces because of clear design and usability guidelines. The complete Firebase Chat Android App source code is built in Android Studio IDE... https://abhiandroid.com/sourcecode/chat
Node.JS is a popular server-side JavaScript framework for handling real-time and distributed data processing. In this session you'll learn what Node.JS is, how it works under the hood, and what scenarios it's useful for. You'll also learn how to deploy it to Windows Azure and manage it inside of IIS 7.
SOAP Web Services have a well established role in the enterprise, but aside from the many benefits of the WS-* standards, SOAP and XML also carry additional baggage for developers. Consequently, REST Web Services are gaining tremendous popularity within the developer community. This session will begin by comparing and contrasting the basic concepts of both SOAP and REST Web Services. Building on that foundation, Sam Brannen will show attendees how to implement SOAP-based applications using Spring-WS 2.0. He will then demonstrate how to build a similar REST-ful application using Spring MVC 3.0. The session will conclude with an in-depth look at both server-side and client-side development as well as efficient integration testing of Web Services using the Spring Framework.
"As an asynchronous event driven JavaScript runtime, Node is designed to build scalable network applications" così si presenta Node.js, piattaforma tecnologica che - grazie alla sua immediatezza e produttività - ha conquistato dapprima startup e piccole aziende, fino a ritagliarsi uno spazio importante in realtà come IBM, LinkedIn, Netflix e Yahoo. La stessa Microsoft ha riconosciuto le potenzialità della piattaforma, tanto da integrare Node.js in Visual Studio Code e nelle ultime release di Visual Studio, oltre a basarci alcuni dei propri servizi di Azure come "Mobile Services" e "Functions".
In questa sessione vedremo come implementare con Node.js alcuni scenari applicativi comuni nell’ambito dello sviluppo web, analizzando quando la sua adozione può portarci vantaggi nel nostro lavoro quotidiano. In conclusione, faremo una breve panoramica architetturale, descrivendo alcuni scenari di cooperazione tra .NET e Node.js nello stesso sistema.
Codice e demo: https://github.com/rucka/CommunityDays2016
A language for the Internet: Why JavaScript and Node.js is right for Internet...Tom Croucher
Increasingly we want to do more with the web and Internet applications we build. We have more features, more data, more users, more devices and all of it needs to be in real-time. With all of these demands how can we keep up? The answer is choosing a language and a platform that are optimized for the kind of architecture Internet and web applications really have. The traditional approach prioritises computation, assigning server resources before they are actually needed. JavaScript and Node.js both take an event driven approach only assigning resources to events as they happen. This allows us to make dramatic gains in performance and resource utilization while still having an environment which is fun and easy to program.
Introduction of server sent events (sse)Yuji KONDO
Server-sent events (SSE) is a technology where a browser receives automatic updates from a server via HTTP connection. The Server-Sent Events EventSource API is standardized as part of HTML5 by the W3C.
Sherlock Homepage - A detective story about running large web services - NDC ...Maarten Balliauw
The site was slow. CPU and memory usage everywhere! Some dead objects in the corner. Something terrible must have happened! We have some IIS logs. Some traces from a witness. But not enough to find out what was wrong. In this session, we’ll see how effective telemetry, a profiler or two as well as a refresher of how IIS runs our ASP.NET web applications can help solve this server murder mystery.
Cloud Script is custom logic written in JavaScript and hosted in the PlayFab service. Games can use this to have server-authoritative logic without the hassles and expense of creating and hosting a full game server. Cloud Script has full access to the PlayFab Server API methods. It enables adding a huge range of game specific features to your title, including ways to do things like granting player rewards, running validation checks to help prevent cheating, or computing the outcome of interactions between players, so that a hacked client can't cheat others (or you). In this webinar we will take a deeper dive into Cloud Script to learn how to extend your game.
Bei Jimdo sammeln wir jede Menge Metriken über alle Teile unseres Systems. Dabei fallen Daten auf allen Ebenen des Systems an: Infrastruktur, System und Applikation. Wichtig ist, dass alle Entwickler zu jedem Zeitpunkt Einblick in die Echtzeit-Metriken ihrer Services nehmen können. Um das zu garantieren, haben wir uns einige Zeit mit der Integration von Prometheus in unsere Systeme beschäftigt.
In unserem Talk werden wir sowohl über den Betrieb von Prometheus als auch über die Integrationen mit dem Rest der Jimdo-Plattform sprechen. Wir werden von Stolpersteinen und Tricks berichten, die wir gelernt haben, sowie einen Einblick in unserer Tool-Landschaft geben.
Mathilde Lemée & Romain Maton
La théorie, c’est bien, la pratique … aussi !
Venez nous rejoindre pour découvrir les profondeurs de Node.js !
Nous nous servirons d’un exemple pratique pour vous permettre d’avoir une premiere experience complete autour de Node.js et de vous permettre de vous forger un avis sur ce serveur Javascript qui fait parler de lui !
http://soft-shake.ch/2011/conference/sessions/incubator/2011/09/01/hands-on-nodejs.html
Similar to Live Streaming & Server Sent Events (20)
DevOps and Testing slides at DASA ConnectKari Kakkonen
My and Rik Marselis slides at 30.5.2024 DASA Connect conference. We discuss about what is testing, then what is agile testing and finally what is Testing in DevOps. Finally we had lovely workshop with the participants trying to find out different ways to think about quality and testing in different parts of the DevOps infinity loop.
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...UiPathCommunity
💥 Speed, accuracy, and scaling – discover the superpowers of GenAI in action with UiPath Document Understanding and Communications Mining™:
See how to accelerate model training and optimize model performance with active learning
Learn about the latest enhancements to out-of-the-box document processing – with little to no training required
Get an exclusive demo of the new family of UiPath LLMs – GenAI models specialized for processing different types of documents and messages
This is a hands-on session specifically designed for automation developers and AI enthusiasts seeking to enhance their knowledge in leveraging the latest intelligent document processing capabilities offered by UiPath.
Speakers:
👨🏫 Andras Palfi, Senior Product Manager, UiPath
👩🏫 Lenka Dulovicova, Product Program Manager, UiPath
UiPath Test Automation using UiPath Test Suite series, part 3DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 3. In this session, we will cover desktop automation along with UI automation.
Topics covered:
UI automation Introduction,
UI automation Sample
Desktop automation flow
Pradeep Chinnala, Senior Consultant Automation Developer @WonderBotz and UiPath MVP
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
JMeter webinar - integration with InfluxDB and GrafanaRTTS
Watch this recorded webinar about real-time monitoring of application performance. See how to integrate Apache JMeter, the open-source leader in performance testing, with InfluxDB, the open-source time-series database, and Grafana, the open-source analytics and visualization application.
In this webinar, we will review the benefits of leveraging InfluxDB and Grafana when executing load tests and demonstrate how these tools are used to visualize performance metrics.
Length: 30 minutes
Session Overview
-------------------------------------------
During this webinar, we will cover the following topics while demonstrating the integrations of JMeter, InfluxDB and Grafana:
- What out-of-the-box solutions are available for real-time monitoring JMeter tests?
- What are the benefits of integrating InfluxDB and Grafana into the load testing stack?
- Which features are provided by Grafana?
- Demonstration of InfluxDB and Grafana using a practice web application
To view the webinar recording, go to:
https://www.rttsweb.com/jmeter-integration-webinar
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
The publishing industry has been selling digital audiobooks and ebooks for over a decade and has found its groove. What’s changed? What has stayed the same? Where do we go from here? Join a group of leading sales peers from across the industry for a conversation about the lessons learned since the popularization of digital books, best practices, digital book supply chain management, and more.
Link to video recording: https://bnctechforum.ca/sessions/selling-digital-books-in-2024-insights-from-industry-leaders/
Presented by BookNet Canada on May 28, 2024, with support from the Department of Canadian Heritage.
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualityInflectra
In this insightful webinar, Inflectra explores how artificial intelligence (AI) is transforming software development and testing. Discover how AI-powered tools are revolutionizing every stage of the software development lifecycle (SDLC), from design and prototyping to testing, deployment, and monitoring.
Learn about:
• The Future of Testing: How AI is shifting testing towards verification, analysis, and higher-level skills, while reducing repetitive tasks.
• Test Automation: How AI-powered test case generation, optimization, and self-healing tests are making testing more efficient and effective.
• Visual Testing: Explore the emerging capabilities of AI in visual testing and how it's set to revolutionize UI verification.
• Inflectra's AI Solutions: See demonstrations of Inflectra's cutting-edge AI tools like the ChatGPT plugin and Azure Open AI platform, designed to streamline your testing process.
Whether you're a developer, tester, or QA professional, this webinar will give you valuable insights into how AI is shaping the future of software delivery.
Elevating Tactical DDD Patterns Through Object CalisthenicsDorra BARTAGUIZ
After immersing yourself in the blue book and its red counterpart, attending DDD-focused conferences, and applying tactical patterns, you're left with a crucial question: How do I ensure my design is effective? Tactical patterns within Domain-Driven Design (DDD) serve as guiding principles for creating clear and manageable domain models. However, achieving success with these patterns requires additional guidance. Interestingly, we've observed that a set of constraints initially designed for training purposes remarkably aligns with effective pattern implementation, offering a more ‘mechanical’ approach. Let's explore together how Object Calisthenics can elevate the design of your tactical DDD patterns, offering concrete help for those venturing into DDD for the first time!
The Art of the Pitch: WordPress Relationships and SalesLaura Byrne
Clients don’t know what they don’t know. What web solutions are right for them? How does WordPress come into the picture? How do you make sure you understand scope and timeline? What do you do if sometime changes?
All these questions and more will be explored as we talk about matching clients’ needs with what your agency offers without pulling teeth or pulling your hair out. Practical tips, and strategies for successful relationship building that leads to closing the deal.
UiPath Test Automation using UiPath Test Suite series, part 4DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 4. In this session, we will cover Test Manager overview along with SAP heatmap.
The UiPath Test Manager overview with SAP heatmap webinar offers a concise yet comprehensive exploration of the role of a Test Manager within SAP environments, coupled with the utilization of heatmaps for effective testing strategies.
Participants will gain insights into the responsibilities, challenges, and best practices associated with test management in SAP projects. Additionally, the webinar delves into the significance of heatmaps as a visual aid for identifying testing priorities, areas of risk, and resource allocation within SAP landscapes. Through this session, attendees can expect to enhance their understanding of test management principles while learning practical approaches to optimize testing processes in SAP environments using heatmap visualization techniques
What will you get from this session?
1. Insights into SAP testing best practices
2. Heatmap utilization for testing
3. Optimization of testing processes
4. Demo
Topics covered:
Execution from the test manager
Orchestrator execution result
Defect reporting
SAP heatmap example with demo
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
State of ICS and IoT Cyber Threat Landscape Report 2024 previewPrayukth K V
The IoT and OT threat landscape report has been prepared by the Threat Research Team at Sectrio using data from Sectrio, cyber threat intelligence farming facilities spread across over 85 cities around the world. In addition, Sectrio also runs AI-based advanced threat and payload engagement facilities that serve as sinks to attract and engage sophisticated threat actors, and newer malware including new variants and latent threats that are at an earlier stage of development.
The latest edition of the OT/ICS and IoT security Threat Landscape Report 2024 also covers:
State of global ICS asset and network exposure
Sectoral targets and attacks as well as the cost of ransom
Global APT activity, AI usage, actor and tactic profiles, and implications
Rise in volumes of AI-powered cyberattacks
Major cyber events in 2024
Malware and malicious payload trends
Cyberattack types and targets
Vulnerability exploit attempts on CVEs
Attacks on counties – USA
Expansion of bot farms – how, where, and why
In-depth analysis of the cyber threat landscape across North America, South America, Europe, APAC, and the Middle East
Why are attacks on smart factories rising?
Cyber risk predictions
Axis of attacks – Europe
Systemic attacks in the Middle East
Download the full report from here:
https://sectrio.com/resources/ot-threat-landscape-reports/sectrio-releases-ot-ics-and-iot-security-threat-landscape-report-2024/
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
Monitoring Java Application Security with JDK Tools and JFR Events
Live Streaming & Server Sent Events
1. Live Streaming
&
Server Sent Events
Tomáš Kramár
@tkramar
2. When?
● Server needs to stream data to client
– Server decides when and what to send
– Client waits and listens
– Client does not need to send messages
– Uni-directional communication
– Asynchronously
6. AJAX polling
Any news?
No
Any news?
No
Browser/Client Server
7. AJAX polling
Any news?
No
Any news?
No
Any news?
Browser/Client Yes! Server
8. AJAX polling
Any news?
No
Any news?
No
Any news?
Browser/Client Yes! Server
Any news?
No
9. AJAX polling
● Overhead
– Establishing new connections, TCP handshakes
– Sending HTTP headers
– Multiply by number of clients
● Not really realtime
– Poll each 2 seconds
11. WebSockets
● bi-directional, full-duplex communication
channels over a single TCP connection
● HTML5
● being standardized
12. Server-Sent Events
● HTML5
● Traditional HTTP
– No special protocol or server implementation
● Browser establishes single connection and
waits
● Server generates events
13. SSE
Request w parameters
id: 1
event: display
data: { foo: 'moo' }
Browser/Client Server
15. Case study
● Live search in trademark databases
● query
– search in register #1
● Search (~15s), parse search result list, fetch each result
(~3s each), go to next page in search result list (~10s),
fetch each result, ...
– search in register #2
● ...
– …
● Don't let the user wait, display results when
they are available
18. Client gotchas
● Special events:
– open
– error
● Don't forget to close the request
self.source.addEventListener('finished', function(e) {
self.status.searchFinished();
self.source.close();
});
19. Server
● Must support
– long-running request
– Live-streaming (i.e., no output buffering)
● Rainbows!, Puma or Thin
● Rails 4 (beta) supports live streaming
20. Rails 4 Live Streaming
class MarksController < ApplicationController
include ActionController::Live
def results
response.headers['Content-Type'] = 'text/event-stream'
sse = SSE.new(response.stream)
Tort.search(params[:query]) do |on|
on.results do |hits|
sse.write(hits, event: 'result')
end
on.status_change do |status|
sse.write(status, event: 'status')
end
on.error do
sse.write({}, event: 'failure')
end
end
end
end
21. require 'json'
class SSE
def initialize io
event: displayn
@io = io data: { foo: 'moo' }nn
end
def write object, options = {}
options.each do |k,v|
@io.write "#{k}: #{v}n"
end
@io.write "data: #{JSON.dump(object)}nn"
end
def close
@io.close
end
end
22. Timeouts, lost connections, internet
explorers and other bad things
● EventSource request can be interrupted
● EventSource will reconnect automatically
● What happens with the data during the time
connection was not available?
23. Handling reconnections
● When EventSource reconnects, we need to
continue sending the data from the point the
connection was lost
– Do the work in the background and store events
somewhere
– In the controller, load events from the storage
● EventSource sends Last-Event-Id in HTTP
header
– But we don't need it if we remove the processed
events
25. class MarksController < ApplicationController
include ActionController::Live
def search!
uuid = UUID.new.generate(:compact)
TORT_QUEUE << { phrase: params[:q], job_id: uuid }
render status: 202, text: marks_results_path(job: uuid)
end
def results
response.headers['Content-Type'] = 'text/event-stream'
sse = SSE.new(response.stream)
queue = SafeQueue.new(Channel.for_job(params[:job]), Tmzone.redis)
finished = false
begin
begin
queue.next_message do |json_message|
message = JSON.parse(json_message)
case message["type"]
when "results" then
sse.write(message["data"], event: 'results')
when "failure" then
sse.write({}, event: 'failure')
when "fatal" then
sse.write({}, event: 'fatal')
finished = true
when "status" then
sse.write(message["data"], event: 'status')
when "finished" then
sse.write({}, event: 'finished')
finished = true
end
end
end while !finished
rescue IOError
# when clients disconnects
ensure
sse.close
end
end
end
26. class MarksController < ApplicationController
include ActionController::Live
def search!
uuid = UUID.new.generate(:compact)
TORT_QUEUE << { phrase: params[:q], job_id: uuid }
generate job_id
render status: 202, text: marks_results_path(job: uuid)
end
def results
response.headers['Content-Type'] = 'text/event-stream'
sse = SSE.new(response.stream)
queue = SafeQueue.new(Channel.for_job(params[:job]), Tmzone.redis)
finished = false
begin
begin
queue.next_message do |json_message|
message = JSON.parse(json_message)
case message["type"]
when "results" then
sse.write(message["data"], event: 'results')
when "failure" then
sse.write({}, event: 'failure')
when "fatal" then
sse.write({}, event: 'fatal')
finished = true
when "status" then
sse.write(message["data"], event: 'status')
when "finished" then
sse.write({}, event: 'finished')
finished = true
end
end
end while !finished
rescue IOError
# when clients disconnects
ensure
sse.close
end
end
end
27. class MarksController < ApplicationController
include ActionController::Live
def search!
uuid = UUID.new.generate(:compact)
TORT_QUEUE << { phrase: params[:q], job_id: uuid }
start async job (GirlFriday)
render status: 202, text: marks_results_path(job: uuid)
end
def results
response.headers['Content-Type'] = 'text/event-stream'
sse = SSE.new(response.stream)
queue = SafeQueue.new(Channel.for_job(params[:job]), Tmzone.redis)
finished = false
begin
begin
queue.next_message do |json_message|
message = JSON.parse(json_message)
case message["type"]
when "results" then
sse.write(message["data"], event: 'results')
when "failure" then
sse.write({}, event: 'failure')
when "fatal" then
sse.write({}, event: 'fatal')
finished = true
when "status" then
sse.write(message["data"], event: 'status')
when "finished" then
sse.write({}, event: 'finished')
finished = true
end
end
end while !finished
rescue IOError
# when clients disconnects
ensure
sse.close
end
end
end
28. class MarksController < ApplicationController
include ActionController::Live
def search!
uuid = UUID.new.generate(:compact)
TORT_QUEUE << { phrase: params[:q], job_id: uuid }
render status: 202, text: marks_results_path(job: uuid)
end
send results URL
def results
response.headers['Content-Type'] = 'text/event-stream'
sse = SSE.new(response.stream)
queue = SafeQueue.new(Channel.for_job(params[:job]), Tmzone.redis)
finished = false
begin
begin
queue.next_message do |json_message|
message = JSON.parse(json_message)
case message["type"]
when "results" then
sse.write(message["data"], event: 'results')
when "failure" then
sse.write({}, event: 'failure')
when "fatal" then
sse.write({}, event: 'fatal')
finished = true
when "status" then
sse.write(message["data"], event: 'status')
when "finished" then
sse.write({}, event: 'finished')
finished = true
end
end
end while !finished
rescue IOError
# when clients disconnects
ensure
sse.close
end
end
end
29. class MarksController < ApplicationController
include ActionController::Live
def search!
uuid = UUID.new.generate(:compact)
TORT_QUEUE << { phrase: params[:q], job_id: uuid }
render status: 202, text: marks_results_path(job: uuid)
end
def results
response.headers['Content-Type'] = 'text/event-stream'
sse = SSE.new(response.stream)
queue = SafeQueue.new(Channel.for_job(params[:job]), Tmzone.redis) Get queue for this job,
finished = false async job is pushing
begin
to this queue
begin
queue.next_message do |json_message|
message = JSON.parse(json_message)
case message["type"]
when "results" then
sse.write(message["data"], event: 'results')
when "failure" then
sse.write({}, event: 'failure')
when "fatal" then
sse.write({}, event: 'fatal')
finished = true
when "status" then
sse.write(message["data"], event: 'status')
when "finished" then
sse.write({}, event: 'finished')
finished = true
end
end
end while !finished
rescue IOError
# when clients disconnects
ensure
sse.close
end
end
end
30. class MarksController < ApplicationController
include ActionController::Live
def search!
uuid = UUID.new.generate(:compact)
TORT_QUEUE << { phrase: params[:q], job_id: uuid }
render status: 202, text: marks_results_path(job: uuid)
end
def results
response.headers['Content-Type'] = 'text/event-stream'
sse = SSE.new(response.stream)
queue = SafeQueue.new(Channel.for_job(params[:job]), Tmzone.redis)
finished = false
begin
begin
queue.next_message do |json_message|
Fetch next message
message = JSON.parse(json_message) from queue (blocks until
case message["type"]
when "results" then one is available)
sse.write(message["data"], event: 'results')
when "failure" then
sse.write({}, event: 'failure')
when "fatal" then
sse.write({}, event: 'fatal')
finished = true
when "status" then
sse.write(message["data"], event: 'status')
when "finished" then
sse.write({}, event: 'finished')
finished = true
end
end
end while !finished
rescue IOError
# when clients disconnects
ensure
sse.close
end
end
end
31. class MarksController < ApplicationController
include ActionController::Live
def search!
uuid = UUID.new.generate(:compact)
TORT_QUEUE << { phrase: params[:q], job_id: uuid }
render status: 202, text: marks_results_path(job: uuid)
end
def results
response.headers['Content-Type'] = 'text/event-stream'
sse = SSE.new(response.stream)
queue = SafeQueue.new(Channel.for_job(params[:job]), Tmzone.redis)
finished = false
begin
begin
queue.next_message do |json_message|
message = JSON.parse(json_message)
case message["type"]
when "results" then
sse.write(message["data"], event: 'results')
when "failure" then
sse.write({}, event: 'failure')
when "fatal" then
sse.write({}, event: 'fatal')
finished = true
when "status" then
sse.write(message["data"], event: 'status')
when "finished" then
sse.write({}, event: 'finished')
finished = true
end
end
end while !finished
rescue IOError
# when clients disconnects IOError is raised when client
ensure
sse.close disconnected and we are
end
end writing to response.stream
end
32. GirlFriday worker
class SearchWorker
def self.perform(phrase, job_id)
channel = Channel.for_job(job_id)
queue = SafeQueue.new(channel, Tmzone.redis)
Tort.search(phrase) do |on|
on.results do |hits|
queue.push({ type: "results", data: hits }.to_json)
end
on.status_change do |status|
queue.push({ type: "status", data: status }.to_json)
end
on.error do
queue.push({ type: 'failure' }.to_json)
end
end
queue.push({ type: "finished" }.to_json)
end
end
33. SafeQueue
class SafeQueue
def initialize(channel, redis)
@channel = channel
@redis = redis
end
def next_message(&block)
begin
_, message = @redis.blpop(@channel)
block.call(message)
rescue => error
@redis.lpush(@channel, message)
raise error
end
end
def push(message)
@redis.rpush(@channel, message)
end
end
34. EventSource Compatibility
● Firefox 6+, Chrome 6+, Safari 5+, Opera 11+,
iOS Safari 4+, Blackberry, Opera Mobile,
Chrome for Android, Firefox for Android
35. Fallback
● Polyfills
– https://github.com/remy/polyfills/blob/master/Event
Source.js
● Hanging GET, waits until the request terminates,
essentially buffering the live output
– https://github.com/Yaffle/EventSource
● send a keep-alive message each 15 seconds
36. Summary
● Unidirectional server-to-client communication
● Single request
● Real-time
● Easy to implement
● Well supported except for IE