-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Server-Sent Events dont work on JRuby #962
Comments
The error message is related to b39d72d The fix is already in master branch. Until a new release is made, you can point the gem to master: # Gemfile
gem 'sinatra', github: 'sinatra/sinatra' Can you try the program on MRI with master branch and check if there's an error? |
Can you confirm/deny whether this is fixed by using master? |
|
Hi @rkh sorry but it seems when I responded earlier, I did so without remembering what the actually problem was that this issue was related to. I've just realised that all the information you need was provided as part of my issue description...
I was already using this as you can see in the example repo I originally provided https://github.com/Integralist/Sinatra-SSE/blob/master/Gemfile#L3
I had already explained as part of the issue description that the issue was with JRuby and NOT MRI -> |
Does this issue still exist on the latest version of JRuby? |
Yep. I just tested with the sinatra master branch and JRuby 9.0.5.0 and the result is exactly the same: the error callback gets executed. |
Here's what I see in the console using latest JRuby 9.1.0.0, on WEBrick and puma:
and:
Here's what I get in the browser console:
I have no idea why the error callback is triggered. Ugh. |
Well, now I can reproduce it with MRI as well. |
Someone should try this again 7 years later with recent versions of everything :) |
I've uploaded an example repo that demonstrates the issue (of which there are two):
https://github.com/Integralist/Sinatra-SSE
The first issue is that SSE doesn't appear to work when using JRuby, but it does work when using MRI (note: the above repo is set to use MRI so it should work; so make sure to switch to JRuby and reinstall dependencies before testing)
Run with
rackup -p 8000
and then you'll be able to access the application viahttp://localhost:8000/
.The home page loads a JavaScript file that opens a connection to
/healthcheck
.The
/healthcheck
endpoint gets passed an even object from/update
. Where/update
is a POST endpoint that receives JSON.You can test this using something like:
There are no obvious errors when using JRuby. The errors reported by JavaScript aren't helpful either.
The output in the terminal (for JRuby) is:
The browser displays something like:
The second issue (with MRI) is a random error that is reported:
...this error occurs every once in a while. I've yet to find any rhyme or reason behind it.
The text was updated successfully, but these errors were encountered: