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', defaultHost: 'localhost',
defaultSecureProtocol: 'https', defaultSecureProtocol: 'https',
defaultPathSeparator: '/', defaultPathSeparator: '/',
websocketAutoReconnect: true,
globalStatStorageCapacity: 120, globalStatStorageCapacity: 120,
taskStatStorageCapacity: 300, taskStatStorageCapacity: 300,
lazySaveTimeout: 500, lazySaveTimeout: 500,

View file

@ -1,7 +1,7 @@
(function () { (function () {
'use strict'; '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 rpcUrl = ariaNgSettingService.getCurrentRpcUrl();
var socketClient = null; var socketClient = null;
@ -72,7 +72,9 @@
var getSocketClient = function (context) { var getSocketClient = function (context) {
if (socketClient === null) { if (socketClient === null) {
try { try {
socketClient = $websocket(rpcUrl); socketClient = $websocket(rpcUrl, {
reconnectIfNotNormalClose: ariaNgConstants.websocketAutoReconnect
});
socketClient.onMessage(function (message) { socketClient.onMessage(function (message) {
if (!message || !message.data) { if (!message || !message.data) {