Skip to content
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

add SSE and WebTransport #3

Open
gedw99 opened this issue Jun 10, 2023 · 8 comments
Open

add SSE and WebTransport #3

gedw99 opened this issue Jun 10, 2023 · 8 comments

Comments

@gedw99
Copy link

gedw99 commented Jun 10, 2023

WS and WSS is currently supported but its relatively easy so add SSE and WebTransport.

Nats subscriptions outputs will then be able to be exposed over WS, WSS, SSE and WebTransport.

WebTransport is now in all major browser and turned on. Safari has it in Tech Preview and will turn it on eventally.

so in the mean time a simple polyfile style like this will do it:
https://github.com/yomorun/presencejs/tree/main/prscd

@nickchomey
Copy link

nickchomey commented Jan 2, 2024

Wow! I've been looking for precisely this functionality - HTTP requests to establish an SSE connection that subscribes to NATS subjects and forwards updates. All within Caddy. So, thanks very much for carrying the original caddy-nats module forward!

So, has anyone made any progress on implementing SSE here, or elsewhere? Either way, I'm happy to pick it up if I can get a bit of guidance!

I also see that you mention Frankenphp in the Readme - it has matured a lot and reached v1 status a month ago. I intend to use it as well for the PHP web app at the core of my broader infrastruture, so would be happy to look into this sort of functionality as well.

Similarly, Frankenphp is made by the same folks as Mercure, which already does SSE+AJAX pubsub through Caddy. I was considering making some sort of NATS transport backend for Mercure, but it seems far more complicated than just adding SSE to this module, and writing custom code for whatever I need,

Anyway, I'm really quite eager about this, so I hope that you'll be able to give a bit of guidance on it all!

@skurfuerst
Copy link
Member

@nickchomey Hey, and sorry for the late reply.

I did not get around to do this yet, and likely won't be able to do it in the upcoming months. However, I'd be more than happy to accept a pull request if it is covered with tests.

Regarding SSE - I think you can model it basically after
https://github.com/sandstorm/caddy-nats-bridge?tab=readme-ov-file#http---nats-via-nats_request-interested-about-response

-> so you create a request handler, which opens a NATS listener; and then replies the received messages via SSE.

All the best,
Sebastian

PS: If I do not react here, feel free to reach out via email; the mail address listed at https://github.com/skurfuerst is correct.

@nickchomey
Copy link

Thanks! As it turns out, I was busy since my previous post. But I'm hoping to return to this in the next week or so and will be eager to implement something like this. Thanks very much for offering to guide me on it - I'm confident that I'll be able to get a PR together with a bit of help!

@gedw99
Copy link
Author

gedw99 commented Mar 17, 2024

@nickchomey

you can contact me via https://github.com/gedw99

I am in transit for the next few days. Long trip back home.

@nickchomey
Copy link

nickchomey commented Mar 21, 2024

I'm going to start exploring this package today. It'll probably take me a few days to wrap my head around this, Caddy and NATS - I'm fairly new to all of them, as well as Golang itself. But I hear they're all relatively simple to learn, and I'm motivated to make this happen (it'll be a great way to learn all of the above anyway!). My priority will be on SSE though - I'm less (not at all) concerned about WebTransport (which, as with most Web innovations, remains unsupported in Safari).

I'm also primarily interested in using this for KV, so it looks like I might need to add some more fundamental mechanisms for interacting with KV and/or Jetstream.

@gedw99, i dont use Telegram or nostr - is there another way you can be reached?

Or, perhaps this issue is the best way for us to continue with this effort?

@nickchomey
Copy link

nickchomey commented Mar 24, 2024

I found the time to dig into Go and Caddy a bit, and got my development environment set up now with step debugging for Go in general, Caddy and this plugin. I wrote a post in the Caddy forum about it. https://caddy.community/t/plugin-development-environment-with-step-debugging/23241/3

It'll now be considerably more easy for me to start working on this SSE feature, as I'll be able to inspect the flow, variables etc...

@gedw99 I signed up for telegram but it wont let me message you. My username is the same as my github username. It would be great to brainstorm some stuff - I see you've been pondering this for years, including talks with Centrifuge to implement NATS SSE.

@gedw99
Copy link
Author

gedw99 commented Mar 27, 2024

I found the time to dig into Go and Caddy a bit, and got my development environment set up now with step debugging for Go in general, Caddy and this plugin. I wrote a post in the Caddy forum about it. https://caddy.community/t/plugin-development-environment-with-step-debugging/23241/3

It'll now be considerably more easy for me to start working on this SSE feature, as I'll be able to inspect the flow, variables etc...

@gedw99 I signed up for telegram but it wont let me message you. My username is the same as my github username. It would be great to brainstorm some stuff - I see you've been pondering this for years, including talks with Centrifuge to implement NATS SSE.

@nickchomey
https://t.me/nickchomey does not work. Says "User name does not exist".
Suggest you add a working telegram URL to your Github profile if you want to chat.

Or you can contact me via gmail. It's just my GitHub name with the AT gmail.com :).

@nickchomey
Copy link

Looks like telegram banned that account for no reason at all. I've created a new one and messaged you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants