From b21f502e625b9de82abf21ddb41bb3818d508518 Mon Sep 17 00:00:00 2001 From: Syrex-o Date: Thu, 9 Mar 2023 13:01:13 +0100 Subject: [PATCH] fix port settings --- libs/services/src/lib/fhem.service.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libs/services/src/lib/fhem.service.ts b/libs/services/src/lib/fhem.service.ts index 658b4c7f..33640aad 100644 --- a/libs/services/src/lib/fhem.service.ts +++ b/libs/services/src/lib/fhem.service.ts @@ -32,6 +32,7 @@ export class FhemService { private deviceRequestCombiner: Subject<{deviceName: string, readingName: string}>|null = null; // connection + public blockReConnect = false; private preventConnect = false; private socket!: WebSocketSubject|null; @@ -97,8 +98,10 @@ export class FhemService { // Login data for basicAuth (connectionProfile.basicAuth ? connectionProfile.USER + ':' + connectionProfile.PASSW + '@' : '' ); - // add ip and port - url += connectionProfile.IP + ':' + connectionProfile.PORT; + // add ip + url += connectionProfile.IP; + // add port + url += (connectionProfile.PORT !== '' ? `:${connectionProfile.PORT}` : ''); if(connectionProfile.type === 'fhemweb') url += '?XHR=1&inform=type=status;filter=.*;fmt=JSON' + '×tamp=' + Date.now(); } @@ -120,6 +123,7 @@ export class FhemService { */ public async testConnectionProfile(profile: ConnectionProfile): Promise{ return new Promise((resolve)=>{ + const testSocket = new WebSocketSubject({ url: this.getConnectionUrl(profile), protocol: profile.type === 'websocket' ? 'json' : '', @@ -189,6 +193,8 @@ export class FhemService { Reconnect handler */ public reconnect(): void{ + if(this.blockReConnect) return; + this.preventConnect = false; this.disconnect(); this.connect();