A couple of weeks ago there was a topic on this forum about listening to an SSE stream (Server Sent Events). Seemed that there was no real SSE client available in Node-Red, so I decided to create node-red-contrib-sse-client.
Will publish it to NPM in a couple of days. Until then it can be installed directly from my Github account: npm install bartbutenaers/node-red-contrib-sse-client
All 'constructive' feedback is more than welcome !
P.S. I have a minor CSS issue. My config screen contains two tables ('events' and 'http headers'), both having the same minimum heigth:
I hoped that both tables would get the same height, however the screenshot shows that the last table has more heigth. Does somebody know how this can be accomplished ?
Tiny comments. The label Url should probably be URL to be consistent. And the prompt Enter URL would be better with a small example. I don’t know SSE so is the URL local? Have a standard pattern ? Have a default?
Hi Paul (@zenofmud), I have uninstalled it on my Raspberry and installed it again but no problems here ...
When you install a node directly from Github, you should refresh your browser window. Otherwise the installed node doesn't appear in the sidebar. Could that be the problem ??
Hi Dave (@dceejay), the code on Github is updated with your feedback (uppercase label, placeholder "http://", and same validation like in the httprequest node):
P.S. the URL can be any SSE server (local or not), like e.g. the SSE demo stream on my readme page. So I cannot add a default URL.
Ok, I uninstalled and installed it and now I see it - it could be that I was looking in the wrong place....
The layout is even for me on the mac in Safari, Chrome and FireFox:
(Bear with me since this is the first time I've heard of SSE) Why the two options when you press '+' in the HTTP headers?
looking at the code is the first the header name and the second the header value? It is not clear to me. Maybe putting a default in both and expanding the explanation would be useful or if the header name is a set possibility, why not make that a pulldown list with all the possibilities.
I must admit that the new version on Github has become a bit more self-explaining:
@zenofmud: the list of possible http header fields is rather large, so not really useful to show them in a dropdown. Instead I have added now a link in the node's info help:
I have published this morning version 0.0.1 to NPM. You can find it here on NPM.
For some reason you cannot find it by searching on NPM, and it is also not visible on flows.nodered.org. Hopefully this is related to the issue that Nick has reported on NPM, and hopefully it will be fixed soon ...
I haven't really used it myself, just developed that node to help some poor souls on this forum...
It is used for clients that want to be notified automatically by a server, for changes that occur on that server. So the clients don't need to poll every X seconds, to ask the server for new changes.
For example your Node-RED editor shows all flow changes of the server (node status updates...). The main difference is that the flow editor uses websockets to implement this. Websockets is a bit similar to SSE, but there are some major differences.
SSE is very useful and under utilised in my opinion. In essence, events are pushed to the client JavaScript. In particular, your JavaScript doesn't have to perform any connection management as the browser takes care of this for you. This, along with a little more structure than WebSockets, is the major selling point.
BTW: Thanks for providing the node! I noticed a small issue where I was unable to use a mustache template declaration in the URL. I got around the issue by constructing the msg.url as an input, but I thought you'd like to know.
Thanks for yor feedback! Indeed I don't support Mustache yet. Will add it when I have time. Have to write it down somewhere, otherwise I'm going to forget it
I have published version 0.2.0 on NPM, which allows the URL to contain the Mustache syntax. Information has been added both in the Info panel and on the Readme page. Please let me know if you have any issues with it...
Hi Bart, I notice it is two years ago you took up my challenge and only now I come back to give it a try. I have imported the demo flow on your (excellent!!) explanation of how to use sse-client.
Now the bad thing is that the node does not connect (red status) (Node-Red on Azure Ubuntu 18.04 VM, as good as new). I did try the curl command you also provided on my Windows laptop, which demonstrates the demo is pushing events. So error is in my Node-red install. Hmmm...
I suspect that the s in https breaks my experience. Would you have straightforward way to fix? Do I need to modify a setting?
Just as a thought.... perhaps you can do me the favor of porting logic from node-red-contrib-https into sse client. That is by far more easy than to configure a TLS setting (for the user, not for you, I acknowledge)
It is not clear to my what you mean with this.
The demo on my readme page uses a "https..." url:
I have tried it and the demo is still working on the latest Node-RED.
Is it this demo that doesn't work in your case?
And why do you think that the "s" is breaking it? Can I assume you have seen some ssl related errors in your log?
Which part of that node are you referring to? With such little information, it is rather hard to understand what you mean.
Am I correct that you mean credentials (username/password), or what do you mean with "TLS setting"? I have never used that node, so just guessing ...
Hi Bart,
I have not modified my NR settings file to enable https (instructions were over my head). Not do I know how to configure a TLS config as if NR is a browser (this time overwhelmed by amount of certificates in the OS).
Hence, I assume my Nose Red does not know how to call an https service, including your SSE client. I did try to prefix url with https, and without but no luck.
The NR-contribute-https behaves just like standard http service node, and has embedded TLS.
I use the node to call a Slack webhook, rudimentary, yes, but this way I sidestep to have to understand OAuth for Slack (do not tell me you see a theme here)
In simple facts
I imported the demo flow for SSE-client, I deployed the tab, and I did look for green for (connection established). There it fails.
Node Red instance is new for now 5 days, as is the Ubuntu 18.04 VM in Azure. Outbound https traffic is no issue (slack webhook)