Does it work if you comment out eventBuilder.name("message-to-client");
? Without that line events will go to the default message handler, which is called "message". (Event names should work, but get the default case working first.)
Also, I don't think onmessage
syntax works, so replace that line with:
eventSource.addEventListener('message',function(event){
document.getElementById('foo').innerHTML = event.data;
},false);
Also, make sure you have the developer tools (network tab) open under Chrome. Your connection is lasting 10 seconds, then the server-side is closing it. Chrome will wait about 3 seconds, the reconnect. So under the network tab, after a while, you should see rows start to stack up, each 10 seconds long. (And, if not, there should be a clue under the console.log.)