auto reconnect when connect aria2 via websocket

This commit is contained in:
MaysWind 2019-04-17 00:23:38 +08:00
parent b57381cb0c
commit 317348ebbd
2 changed files with 5 additions and 2 deletions

View file

@ -13,6 +13,7 @@
defaultHost: 'localhost',
defaultSecureProtocol: 'https',
defaultPathSeparator: '/',
websocketAutoReconnect: true,
globalStatStorageCapacity: 120,
taskStatStorageCapacity: 300,
lazySaveTimeout: 500,

View file

@ -1,7 +1,7 @@
(function () {
'use strict';
angular.module('ariaNg').factory('aria2WebSocketRpcService', ['$q', '$websocket', 'ariaNgSettingService', 'ariaNgLogService', function ($q, $websocket, ariaNgSettingService, ariaNgLogService) {
angular.module('ariaNg').factory('aria2WebSocketRpcService', ['$q', '$websocket', 'ariaNgConstants', 'ariaNgSettingService', 'ariaNgLogService', function ($q, $websocket, ariaNgConstants, ariaNgSettingService, ariaNgLogService) {
var rpcUrl = ariaNgSettingService.getCurrentRpcUrl();
var socketClient = null;
@ -72,7 +72,9 @@
var getSocketClient = function (context) {
if (socketClient === null) {
try {
socketClient = $websocket(rpcUrl);
socketClient = $websocket(rpcUrl, {
reconnectIfNotNormalClose: ariaNgConstants.websocketAutoReconnect
});
socketClient.onMessage(function (message) {
if (!message || !message.data) {