-
-
Notifications
You must be signed in to change notification settings - Fork 752
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
HTML5 HTTP/2 SSE Transport Support #369
Comments
From what I could see, it does not seem as if Express will support HTTP2 any time soon so this will be very dependent on #258. |
I did do some spelunking in this area a couple weeks back. I guess you can get it to work with Express5 but who knows what is going on with that branch. Here's an example from Stackoverflow. There is also the Realistically, it definitely depends on #258 and likely not something that will happen in the very near term. |
@daffl it's quite easy to implement a http2 server with: https://github.com/indutny/node-spdy |
I had some discussion about this in Slack with @MichaelErmer. He's using Nginx like so:
with Nginx handling http2. IMHO this might be the more appropriate way to do things and Feathers likely shouldn't care about HTTP2 directly with the following caveats:
Barring those considerations it may or may not make sense to include HTTP2 as a transport. Still some more investigation to do.... |
Restify is adding http/2 support restify/node-restify#1489 |
I agree that using nginx Feathers shouldn't care about HTTP/2 it even more it may be mounted even without SSL but nevertheless here's my working example: // at the the very bottom of the app.js
// Enable https server
const ssl = app.get('ssl'); // get ssl configurations from config.json
let server;
if (ssl) {
server = spdy.createServer({
key: fs.readFileSync(path.resolve(__dirname, ssl.key)),
cert: fs.readFileSync(path.resolve(__dirname, ssl.cert)),
}, app);
} else {
server = spdy.createServer(app);
}
app.setup(server);
module.exports = { app, server };
// index.js
const { app, server } = require('./app');
const port = app.get('port');
// feathers-socketio explicitly creates http server
server.listen(port); // call `listen` on the server |
* Logout should always give a response. I'm not sure what the correct way to handle this is, but this fixes feathersjs-ecosystem/authentication-client#10. * Make sure it’s a function before trying to call it I somehow encountered a scenario where callback didn’t exist, so this catches it. For some reason I can’t seem to test logging out when not logged in.
* Logout should always give a response. I'm not sure what the correct way to handle this is, but this fixes feathersjs-ecosystem/authentication-client#10. * Make sure it’s a function before trying to call it I somehow encountered a scenario where callback didn’t exist, so this catches it. For some reason I can’t seem to test logging out when not logged in.
You can install https://www.ssllabs.com/ssltest/analyze.html gave me the same A+ score for |
Is HTTP2 now supported in 2022? Can I implement a SSE source now with FeathersJS? |
Yes, using a reverse proxy like |
It is relatively simple to add import { createSession, createChannel } from 'better-sse';
import { IncomingMessage, ServerResponse } from 'http';
export default function (app: any): void {
const debugSseSource = require('debug')('sseSource');
const sseChannel = createChannel();
// Order creations
const orders: any = app.service('orders'); // use endpoint URL
app.get('/v1/admin/orders', async (req: IncomingMessage, res: ServerResponse) => {
// on new connections, add SSE session to SSE channel
const sseSession = await createSession(req, res);
sseChannel.register(sseSession);
debugSseSource('Client (orders) has joined.');
//res.end(); // @TODO/PROBLEM without the whole FeathersJS app hangs - but it stops the request...
});
orders.on('created', (order: any) => {
// broadcast to all clients
debugSseSource('order created');
sseChannel.broadcast(order, 'created');
});
}; Related SO discussion: https://stackoverflow.com/a/71466957/4150808 |
2023 any update ? |
+1, as SSE is ideal for notifications / browser push, even better so than web sockets. I had a discussion on Discord about adding SSE natively, the concensus was that Websockets are a kind of functional superset of SSE. Maybe add a plugin package for FeathersJS that adds SSE? |
I love that Feathers builds out API endpoints for services with both REST and multiple websocket providers. It may be of interest to additionally support an HTTP/2 SSE transport provider.
http://docs.feathersjs.com/providers/
I searched for this issue but didn't find it yet despite it being mentioned 4 months ago on a hacker news discussion (referenced below).
Thanks!
https://hn.algolia.com/story/11290577/feathers-2-0-a-minimalist-real-time-javascript-framework
The text was updated successfully, but these errors were encountered: