You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Recently started with Hapi and was trying to get server sent events working, as I was running into troubles I found #1008 - but the example in there did not work for me. In fact I got a very strange behavior, because inspecting the result with curl seemed to look the same, but in neither Chrome nor Firefox I got the onmessage events.
To demonstrate the behavior I've written a sample server in both Hapi and plain node.js (might add that plain node.js works): https://gist.github.com/lwe/8982052 The output from curl is for both versions actually (and funnily) enough the same.
Start the server by running either node hapi.js or node plain.js and then go to http://localhost:8000/hello, then check the debug console for any output.
OK: plain.js in Chrome
Looks good abcdef is printed on the screen multiple times, also in the Network tab it looks like
NOK: hapi.js in Chrome
In Network tab it is marked as pending, it looks like the stream is not flushed or something.
Summary
I get the same behavior in Firefox actually. However, when checking the output with curl I do get the exactly same (!) output for both the Hapi and plain node variant, I've no idea why neither Chrome nor Firefox are getting the onmessage calls.
Any help is appreciated, thanks in advance.
The text was updated successfully, but these errors were encountered:
Minor update, but when working with request.raw.res instead of the reply() method it works as expected, though I somehow suppose I haven't yet understood how reply() actually works...
The problem with your example was missing header('Content-Encoding', 'identity') to prevent the server from gzipping the data. This looks like a browser bug to me but I don't know anything about this. I added a new example for server sent events, as well as a new request 'disconnect' event to remove the need to interact with the raw constructs.
Actually, I tried setting Content-Encoding: identity header, but probably in a different combination, because it did not work for me. Yes, the funny thing is that the "pure" node.js variant still uses Content-Encoding: chunked, somehow the browser does not continue reading the stream, very weird - but well it works now.
PS: Very, very nice work on Hapi and all the related modules.
This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.
lockbot
locked as resolved and limited conversation to collaborators
Jan 9, 2020
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Recently started with Hapi and was trying to get server sent events working, as I was running into troubles I found #1008 - but the example in there did not work for me. In fact I got a very strange behavior, because inspecting the result with
curl
seemed to look the same, but in neither Chrome nor Firefox I got theonmessage
events.To demonstrate the behavior I've written a sample server in both Hapi and plain node.js (might add that plain node.js works): https://gist.github.com/lwe/8982052 The output from
curl
is for both versions actually (and funnily) enough the same.Start the server by running either
node hapi.js
ornode plain.js
and then go tohttp://localhost:8000/hello
, then check the debug console for any output.OK: plain.js in Chrome
Looks good
abcdef
is printed on the screen multiple times, also in the Network tab it looks likeNOK: hapi.js in Chrome
In Network tab it is marked as pending, it looks like the stream is not flushed or something.
Summary
I get the same behavior in Firefox actually. However, when checking the output with
curl
I do get the exactly same (!) output for both the Hapi and plain node variant, I've no idea why neither Chrome nor Firefox are getting theonmessage
calls.Any help is appreciated, thanks in advance.
The text was updated successfully, but these errors were encountered: