Comments (18)
Hi, could you try to remove source.inactivity_timeout = 0
?
from em-eventsource.
I only added that line in an attempt to solve the problem.
from em-eventsource.
Ok, could you give me a working sinatra server to reproduce it?
from em-eventsource.
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.
Would you like me to email you the address and port at [email protected] ?
from em-eventsource.
Hi Sod, having some code to reproduce it locally would be easier for me.
from em-eventsource.
Oh, I see. You want some Ruby to host a server. Give me ten minutes.
from em-eventsource.
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.
With angelo, I didn't manage to make it works. With my own sse server, it works like a charm.
from em-eventsource.
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.
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.
There is a crash on the angelo server code you gave me. Could you give me a more complete example ?
from em-eventsource.
That is pretty much the exact code I am using. What was the crash?
from em-eventsource.
Something about report_errors. Don't have the exact crash at this moment.
from em-eventsource.
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.
Okay, I found the issue. I'll try to fix it soon.
from em-eventsource.
Great
from em-eventsource.
The issue has been fixed and I released the version 0.2.2 on rubygems.
from em-eventsource.
Related Issues (6)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from em-eventsource.