
Even when running the https://github.com/strongloop/angular-live-set-example example, I get console errors in Chrome console:
net::ERR_INCOMPLETE_CHUNKED_ENCODING
I don't have compression in my middleware stack, with compression it doesn't work at all. So the events work just fine, but the errors are annoying, because to filter through it all looking for other issues is problematic. Also it just doesn't look great when you have 100's of errors in the console after a couple of hours...
The error writes to console every 2 minutes it seems. So it would seem like at some point the EventSource connection to the loopback server times out and then automatically reconnects (since it still works even with the errors). I can also see that when the error occurs a new GET request is made to the change stream endpoint.
So in loopback, is there a way to send some "keep alive" packets to the client every minute or so?
If no one else is experiencing this issue, what causes it on my PC?
Any help would be appreciated!
Hi @EmileSpecs
Thanks for reporting the issue. I am having a look to reproduce and getting back to you on that.
Hi @loay, thanks!
I've now also found another problem caused by change streams. In my app I register 6 change stream listeners (in my main Angular app controller), when they're enabled all other requests remain pending until the EventSources throw the errors above and then they return responses.
So my app basically doesn't function when I have these 6 change streams registered. Do these change streams somehow block other responses? Are they using up all available event listeners for http traffic?
Is there somehow I can investigate this? To replicate you could perhaps also register 6+ change streams:
// The change streams are linked to 6 different models that I need changes from
src = new EventSource(urlBase + url +'/change-stream?access_token='+ LoopBackAuth.accessTokenId);
And then see if other requests to the server is blocked like mine. When I don't register these change stream listeners, everything works perfectly fine...
@EmileSpecs
is your app somewhere on github so I can try reproducing using your app?
Thanks
@loay, unfortunately I don't. Like I mentioned in the first comment, I get those errors with the example app as well. So that would be a good start.
I will try and also add a couple more models to the example app and then see if I have the same "blocking" issues as I have in my own app.
Figuring out why there are these net::ERR_INCOMPLETE_CHUNKED_ENCODING errors occur would be a good start and that I get with the example app.
Also getting similar issues.
net::ERR_INCOMPLETE_CHUNKED_ENCODINGI have tested with different browser and even react-native always getting the same behavior. After 60s timeout. Checked all configs and headers for nginx and loopback.
@EmileSpecs @JonnyBGod
I cannot reproduce the issue on my end. I did some search and I found that some people got that issue fixed once they disabled the Real time protection on the Anti-Virus. Others had that issue related to the Cache Control.
I am on mac, no antivirus cache disabled on chrome when devtools are open.
My main problem is not related to the error though. I am concerned about the timeout after one minute of inactivity.
@JonnyBGod, Is your code on a repo that you can refer me to so I can try to reproduce?
Thanks
@loay I am not doing anything special. The angular-live demo has the same behavior.
Tried a lot of different setups now.
The connections always times out after 60 seconds of inactivity.
Another test using curl and connecting direct to loopback server.
curl -H Accept:text/event-stream "http://192.168.1.75:52447/api/rides/change-stream?_format=event-source&access_token=vcuEpumlI0qC6mwWk2ZMvkeGKBLLYPpz"
:ok
curl: (18) transfer closed with outstanding read data remaining
Around one and two minutes between ok and close.
Ok. Just found out the problem.
What is causing the drop in connection is the default nodejs http socket timeout of two minutes.
I did a quick work around with a middleware that changes the timeout and sets header for every route containing 'change-stream'.
app.middleware('routes:before', function (req, res, next) {
if (req.path.indexOf('change-stream') !== -1) {
res.setTimeout(24*3600*1000);
res.set('X-Accel-Buffering', 'no');
return next();
} else {
return next();
}
});
This is not the best way to fix the issue and should be considered a quick work around.
The PersistantModel createChangeStream function should deal with this.
@JonnyBGod
Thanks I will have a look. I will get back to you as soon as I can.
Hi,
the issue has been reported to include a feature for a similar case: https://github.com/strongloop/angular-live-set/issues/11
Closing this issue for now.
@EmileSpecs Hi. You solved problem 6 connections?
I got this problem even not using Angular Live Set. Did you guys managed how to solve it?
Most helpful comment
Ok. Just found out the problem.
What is causing the drop in connection is the default nodejs http socket timeout of two minutes.
I did a quick work around with a middleware that changes the timeout and sets header for every route containing 'change-stream'.
This is not the best way to fix the issue and should be considered a quick work around.
The PersistantModel createChangeStream function should deal with this.