Fix acceleration websocket ping/pong
This commit is contained in:
		
							parent
							
								
									7d3d59c348
								
							
						
					
					
						commit
						f1e2c893cc
					
				| @ -49,8 +49,8 @@ class AccelerationApi { | |||||||
|   private websocketPath = config.MEMPOOL_SERVICES?.API ? `${config.MEMPOOL_SERVICES.API.replace('https://', 'wss://').replace('http://', 'ws://')}/accelerator/ws` : '/'; |   private websocketPath = config.MEMPOOL_SERVICES?.API ? `${config.MEMPOOL_SERVICES.API.replace('https://', 'wss://').replace('http://', 'ws://')}/accelerator/ws` : '/'; | ||||||
|   private _accelerations: Record<string, Acceleration> = {}; |   private _accelerations: Record<string, Acceleration> = {}; | ||||||
|   private lastPoll = 0; |   private lastPoll = 0; | ||||||
|   private lastPing = 0; |   private lastPing = Date.now(); | ||||||
|   private lastPong = 0; |   private lastPong = Date.now(); | ||||||
|   private forcePoll = false; |   private forcePoll = false; | ||||||
|   private myAccelerations: Record<string, { status: MyAccelerationStatus, added: number, acceleration?: Acceleration }> = {}; |   private myAccelerations: Record<string, { status: MyAccelerationStatus, added: number, acceleration?: Acceleration }> = {}; | ||||||
| 
 | 
 | ||||||
| @ -283,6 +283,7 @@ class AccelerationApi { | |||||||
| 
 | 
 | ||||||
|         this.ws.on('pong', () => { |         this.ws.on('pong', () => { | ||||||
|           logger.debug('received pong from acceleration websocket server'); |           logger.debug('received pong from acceleration websocket server'); | ||||||
|  |           this.lastPong = Date.now(); | ||||||
|         }); |         }); | ||||||
|       } else { |       } else { | ||||||
|         if (this.lastPing > this.lastPong && Date.now() - this.lastPing > 10000) { |         if (this.lastPing > this.lastPong && Date.now() - this.lastPing > 10000) { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user