mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-04 19:15:04 -04:00
Added a timeout(40s) to $http stream requests (/events) in order to be notified by an error when there is a network issue. Thus, we can retry with a new request.
This commit is contained in:
parent
d1bf659ed7
commit
ee079cd250
2 changed files with 27 additions and 10 deletions
|
@ -25,7 +25,8 @@ the eventHandlerService.
|
|||
angular.module('eventStreamService', [])
|
||||
.factory('eventStreamService', ['$q', '$timeout', 'matrixService', 'eventHandlerService', function($q, $timeout, matrixService, eventHandlerService) {
|
||||
var END = "END";
|
||||
var TIMEOUT_MS = 30000;
|
||||
var SERVER_TIMEOUT_MS = 30000;
|
||||
var CLIENT_TIMEOUT_MS = 40000;
|
||||
var ERR_TIMEOUT_MS = 5000;
|
||||
|
||||
var settings = {
|
||||
|
@ -55,7 +56,7 @@ angular.module('eventStreamService', [])
|
|||
deferred = deferred || $q.defer();
|
||||
|
||||
// run the stream from the latest token
|
||||
matrixService.getEventStream(settings.from, TIMEOUT_MS).then(
|
||||
matrixService.getEventStream(settings.from, SERVER_TIMEOUT_MS, CLIENT_TIMEOUT_MS).then(
|
||||
function(response) {
|
||||
if (!settings.isActive) {
|
||||
console.log("[EventStream] Got response but now inactive. Dropping data.");
|
||||
|
@ -80,7 +81,7 @@ angular.module('eventStreamService', [])
|
|||
}
|
||||
},
|
||||
function(error) {
|
||||
if (error.status == 403) {
|
||||
if (error.status === 403) {
|
||||
settings.shouldPoll = false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue