After lots of try and testing , i found that the Local server do not support sse with cors in browser ?
below is my code, which got nothing error, the connection will keep connected, but nothing got in browser , after debugging the server found : it will return โ/nโ from server continued without error.
var evtSource = new EventSource("http://192.168.1.100:8080/v1/events/my-event?access_token=d4074326f6002dAAAAAAAAAAb98ad773d76ad2b1");
evtSource.onmessage = function(e) {
alert("EventSource failed.");
$( "#container3" ).append( "<strong> YES, we now receive the event from serve side ! " + "</strong> !" );
}
evtSource.onerror = function(e) {
alert("EventSource failed.");
};
So I'm guessing the issue is more about specifying the specific event name when binding your eventSource object. Checkout this post for an example of how to bind to a specific eventsource topic:
The code of emc2 are using the sse simulator in nodejs which is different with my way which i am calling the cloud server on the browser side directlly.
I just test the way from emc2 it works fine . and maybe the better choice for me .
Ahh, thanks for clarifying! I think this makes sense, and might be related to some features Iโd like to add to the local cloud the next chance I get.