Giter Site home page Giter Site logo

Comments (18)

francois2metz avatar francois2metz commented on May 28, 2024

Hi, could you try to remove source.inactivity_timeout = 0?

from em-eventsource.

Sod-Almighty avatar Sod-Almighty commented on May 28, 2024

I only added that line in an attempt to solve the problem.

from em-eventsource.

francois2metz avatar francois2metz commented on May 28, 2024

Ok, could you give me a working sinatra server to reproduce it?

from em-eventsource.

Sod-Almighty avatar Sod-Almighty commented on May 28, 2024

I will open a port on my router to allow you to access the locally-hosted server. Give moment.

Incidentally, I misspoke slightly in the original report. I am actually using Angelo, rather than Sinatra.

from em-eventsource.

Sod-Almighty avatar Sod-Almighty commented on May 28, 2024

Would you like me to email you the address and port at [email protected] ?

from em-eventsource.

francois2metz avatar francois2metz commented on May 28, 2024

Hi Sod, having some code to reproduce it locally would be easier for me.

from em-eventsource.

Sod-Almighty avatar Sod-Almighty commented on May 28, 2024

Oh, I see. You want some Ruby to host a server. Give me ten minutes.

from em-eventsource.

Sod-Almighty avatar Sod-Almighty commented on May 28, 2024

Alright, try this:

#!/usr/bin/env ruby
require 'angelo'

class HTTPServer < Angelo::Base
	report_errors!
	def self.start!
		addr '0.0.0.0'
		port 2347
	end
	eventsource '/sse' do |s|
		s.responder.content_type :json
		sses[:notification] << s
	end
	get '/' do
		halt 200, "Nothing to see here"
	end
	def self.notify **data
		sses[:notification].event **data
	end
end

Thread.new do
	while true
		sleep 1
		begin
			HTTPServer.notify test: "test"
		rescue Exception => e
			puts e
		end
	end
end
HTTPServer.start!
HTTPServer.run!

from em-eventsource.

francois2metz avatar francois2metz commented on May 28, 2024

With angelo, I didn't manage to make it works. With my own sse server, it works like a charm.

from em-eventsource.

Sod-Almighty avatar Sod-Almighty commented on May 28, 2024

Well, the Linux sse command connects to Angelo fine:

# ~/sse/bin/sse -i http://nas:2347/sse
EVENT event:<none> (19 byte)
EVENT=notification
�<�
{"test":"test"}

EVENT event:<none> (16 byte)
EVENT=notification

{"test":"test"}

EVENT event:<none> (16 byte)
EVENT=notification

{"test":"test"}

Compiling the sse command is a pain in the bum, but I eventually managed it. And the fact that it works kinda suggests that it's your gem at fault.

from em-eventsource.

Sod-Almighty avatar Sod-Almighty commented on May 28, 2024

Also, I have used SSE successfully in Javascript on my intranet before, with an Angelo server, and that works also. Sorry dude, it's not Angelo to blame here.

from em-eventsource.

francois2metz avatar francois2metz commented on May 28, 2024

There is a crash on the angelo server code you gave me. Could you give me a more complete example ?

from em-eventsource.

Sod-Almighty avatar Sod-Almighty commented on May 28, 2024

That is pretty much the exact code I am using. What was the crash?

from em-eventsource.

francois2metz avatar francois2metz commented on May 28, 2024

Something about report_errors. Don't have the exact crash at this moment.

from em-eventsource.

francois2metz avatar francois2metz commented on May 28, 2024

For some unknown reason, the socket is immediately closed on one side. Don't know what's wrong. It only happens with angelo for now.

from em-eventsource.

francois2metz avatar francois2metz commented on May 28, 2024

Okay, I found the issue. I'll try to fix it soon.

from em-eventsource.

Sod-Almighty avatar Sod-Almighty commented on May 28, 2024

Great

from em-eventsource.

francois2metz avatar francois2metz commented on May 28, 2024

The issue has been fixed and I released the version 0.2.2 on rubygems.

from em-eventsource.

Related Issues (6)

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.