Giter Site home page Giter Site logo

francois2metz / em-eventsource Goto Github PK

View Code? Open in Web Editor NEW
84.0 36.0 28.0 72 KB

em-eventsource is an eventmachine library to consume Server-Sent Events streaming API.

License: MIT License

Ruby 100.00%
eventmachine eventsource eventsource-implementations ruby sse-client

em-eventsource's People

Contributors

dependabot[bot] avatar francois2metz avatar musikanimal avatar oruen avatar peikk0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

em-eventsource's Issues

error Connection lost. Reconnecting

I'm convinced this gem is utterly broken:

EM.run do
	source = EventMachine::EventSource.new "http://nas:2347/sse", {}, {'Accept' => 'text/event-stream'}
	source.inactivity_timeout = 0
	source.message do |message|
		puts message
	end
	source.on "notification" do |message|
		puts "notification #{message}"
	end
	source.error do |error|
		puts "error #{error}"
	end
	source.open do
		puts "opened"
	end
	source.start # Start listening
end
opened
error Connection lost. Reconnecting.
opened
error Connection lost. Reconnecting.
opened
error Connection lost. Reconnecting.
...

Sinatra server output:

I, [2018-05-15T09:24:00.199421 #12430]  INFO -- : 10.0.0.2 - - "SSE /sse HTTP/1.1" 200 -
W, [2018-05-15T09:24:00.200600 #12430]  WARN -- : closed stream
I, [2018-05-15T09:24:03.205054 #12430]  INFO -- : 10.0.0.2 - - "SSE /sse HTTP/1.1" 200 -
W, [2018-05-15T09:24:03.210790 #12430]  WARN -- : closed stream
I, [2018-05-15T09:24:06.211593 #12430]  INFO -- : 10.0.0.2 - - "SSE /sse HTTP/1.1" 200 -
W, [2018-05-15T09:24:06.212589 #12430]  WARN -- : closed stream

I've spent two hours trying to debug this, and I'm none the wiser.

Bundler 1.1 compatibility

While using this gem with Bundler 1.1.rc7 I've run into this issue while trying to update some unrelated gem:

$ bundle update somegem
Fetching gem metadata from http://rubygems.org/.
Unfortunately, the gem em-eventsource (0.1.1) has an invalid gemspec. As a result, Bundler cannot install this Gemfile. Please ask the gem author to yank the bad version to fix this issue. For more information, see http://bit.ly/syck-defaultkey.

Could you please yank 0.1.1 gem version or provide some other workaround except using Bundler 1.0?

em-http-request CVE causing a TLS warning

The em-http-request gem recently published a new version (1.1.6) which highlights a CVE around a Man in the Middle attack: igrigorik/em-http-request#339. Is it possible to have the gem use TLS by default?

I am getting this warning when using this gem in various projects:

[WARNING; em-http-request] TLS hostname validation is disabled (use 'tls: {verify_peer: true}'), see CVE-2020-13482 and https://github.com/igrigorik/em-http-request/issues/339 for details

Getting disconnected -- is it the server's problem?

I'm not very familiar with SSE and where to look for the reasons behind disconnections. I'm trying to connect to https://horizon.stellar.org/operations:

Modifying examples/simple.rb:

require 'em-eventsource'

EM.run do
  source = EM::EventSource.new("https://horizon.stellar.org/operations")
  source.retry = 3

  source.message do |message|
    puts "new message #{message}"
    # puts "New Message"
  end

  source.error do |error|
    puts "error #{error}"
  end

  source.start
end

It disconnects immediately, and then retries 1 second later (the server has a retry header of 1000).

Mind pointing me to the right direction to figure out why it's getting disconnected?

Handle cross-origin redirection

I'm trying to stream events from Nest as shown here: https://developers.nest.com/documentation/cloud/rest-streaming-guide

In general im doing:

      source = EventMachine::EventSource.new(event_url, query = {}, headers=
                                            {'Authorization' => "Bearer #{@token}",
                                            'Accept' => 'text/event-stream',
                                            'Cache-Control' => 'no-cache' })

where event url is "https://developer-api.nest.com/". I get a 401 Unauthorized Error and is addressed by Nest at: https://developers.nest.com/documentation/cloud/how-to-handle-redirects which suggests that eventsource is not handling redirects properly. This is confirmed when I swap the event_url with the final redirect address and the stream works fine. Any way to add the ability to handle redirects to the library? Thanks alot!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.