add automatic backoff when server is at capacity
This commit is contained in:
		| @@ -1145,7 +1145,12 @@ function on_ws_recv(evt) { | ||||
|                         break; | ||||
|                     case 'pocsag_data': | ||||
|                         update_pocsag_panel(json['value']); | ||||
|                         break | ||||
|                         break; | ||||
|                     case 'backoff': | ||||
|                         divlog("Server is currently busy: " + json['reason'], true); | ||||
|                         // set a higher reconnection timeout right away to avoid additional load | ||||
|                         reconnect_timeout = 16000; | ||||
|                         break; | ||||
|                     default: | ||||
|                         console.warn('received message of unknown type: ' + json['type']); | ||||
|                 } | ||||
|   | ||||
| @@ -3,7 +3,7 @@ from owrx.dsp import DspManager | ||||
| from owrx.cpu import CpuUsageThread | ||||
| from owrx.sdr import SdrService | ||||
| from owrx.source import SdrSource | ||||
| from owrx.client import ClientRegistry | ||||
| from owrx.client import ClientRegistry, TooManyClientsException | ||||
| from owrx.feature import FeatureDetector | ||||
| from owrx.version import openwebrx_version | ||||
| from owrx.bands import Bandplan | ||||
| @@ -86,7 +86,12 @@ class OpenWebRxReceiverClient(Client): | ||||
|         self.configSub = None | ||||
|         self.connectionProperties = {} | ||||
|  | ||||
|         ClientRegistry.getSharedInstance().addClient(self) | ||||
|         try: | ||||
|             ClientRegistry.getSharedInstance().addClient(self) | ||||
|         except TooManyClientsException: | ||||
|             self.write_backoff_message("too many clients") | ||||
|             self.close() | ||||
|             raise | ||||
|  | ||||
|         pm = PropertyManager.getSharedInstance() | ||||
|  | ||||
| @@ -316,6 +321,9 @@ class OpenWebRxReceiverClient(Client): | ||||
|     def write_pocsag_data(self, data): | ||||
|         self.send({"type": "pocsag_data", "value": data}) | ||||
|  | ||||
|     def write_backoff_message(self, reason): | ||||
|         self.send({"type": "backoff", "reason": reason}) | ||||
|  | ||||
|  | ||||
| class MapConnection(Client): | ||||
|     def __init__(self, conn): | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Jakob Ketterl
					Jakob Ketterl