mafintosh / signalhub

Simple signalling server that can be used to coordinate handshaking with webrtc or other fun stuff.
MIT License
667 stars 97 forks source link

broadcast requests not flushing? #16

Closed kevzettler closed 8 years ago

kevzettler commented 8 years ago
signalhub@4.3.1

I'm using signalhub for webrtc signaling. I have a client(browser) - server(node) setup. I noticed the client was never reciving the signalhub broadcasts from the server. Even though they we're captured in the signalhub logs indicating the server was sending them.

If I kill the signalhub process the requests are flushed to the client and the webrtc handshake is successful.

If I let the requests timeout I get a browser console error

GET http://104.236.179.183:8080/v1/plebland/server_1454636230546_ack net::ERR_INCOMPLETE_CHUNKED_ENCODING

I looked in the network tab and it looks like maybe the eventsource requests are not terminating?

screenshot 2016-02-04 17 49 08

I'm running this on digital ocean you can check the client: http://104.236.179.183:8888/

mafintosh commented 8 years ago

Are you running a server in front of the signalhub by change? like nginx etc

kevzettler commented 8 years ago

I personally am not. I'm running this on a fresh Digital Ocean Ubuntu Droplet using ./node_modules/.bin/signalhub listen -p 8080

I should add that this works fine for me when hosted from a local Vagrant instance.

You had the same thought as me. I've worked with EventSource in the past and seen behavior like this http://stackoverflow.com/questions/29807834/express-js-not-streaming-chunked-text-event-stream-resposne Usually related to a proxy not handling the chunking correctly or something. Wondering if Digital Ocean has some other front proxy here.

I've also seen other solutions outside of proxy config. Where you need to send certian whitespace character suffixs to properly denote chunks to to the browser. Or the mime type should be text/json or something.

Appreciate your review.

kevzettler commented 8 years ago

Another important piece here is that the server(node) is getting events broadcast correctly to it from the same signalhub instance. Which is leading me to belive it might be some browser issue or the signalhub client? maybe some cross domain thing? Looks like its corisfied though.

mafintosh commented 8 years ago

Do you have the signalhub up and running? This links http://104.236.179.183:8888 redirects me to your website

kevzettler commented 8 years ago

Yeah sorry signal hub is at port 8080 http://104.236.179.183:8080

kevzettler commented 8 years ago

so i'm able to reproduce the behavior using curl

I subscribe like:

curl 'http://104.236.179.183:8080/v1/plebland/heartbeat' -H 'Accept: text/event-stream' -H 'Cache-Control: no-cache' -H 'Origin: http://104.236.179.183:8888' -H 'Referer: http://104.236.179.183:8888/' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.103 Safari/537.36' --compressed

and spam a few broadcasts like:

./node_modules/.bin/signalhub broadcast plebland heartbeat '{"hello":"world"}' -p 8080 -h 104.236.179.183

curl dosen't do anything. I can see the broadcasts in the signalhub server log. If I kill the signalhub process they are all flushed

data: {"hello":"world"}

data: {"hello":"world"}

data: {"hello":"world"}

data: {"hello":"world"}

curl: (18) transfer closed with outstanding read data remaining
kevzettler commented 8 years ago

oh man so this is just brutal. No problem with signalhub. Great peice of software. But I have an anti virus installed on my machine Sophos and apparently it blocks SSE

https://community.sophos.com/products/free-antivirus-tools-for-desktops/f/17/t/5750

Thanks for looking at this. Hopefully it will help some one in the future

mafintosh commented 8 years ago

wow! glad you figured this out. thats kinda crazy that it would do that