Skip to content

Commit

Permalink
fix port settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Syrex-o committed Mar 9, 2023
1 parent 1852e3e commit b21f502
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions libs/services/src/lib/fhem.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<any>|null;

Expand Down Expand Up @@ -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' + '&timestamp=' + Date.now();
}
Expand All @@ -120,6 +123,7 @@ export class FhemService {
*/
public async testConnectionProfile(profile: ConnectionProfile): Promise<boolean>{
return new Promise((resolve)=>{

const testSocket = new WebSocketSubject({
url: this.getConnectionUrl(profile),
protocol: profile.type === 'websocket' ? 'json' : '',
Expand Down Expand Up @@ -189,6 +193,8 @@ export class FhemService {
Reconnect handler
*/
public reconnect(): void{
if(this.blockReConnect) return;

this.preventConnect = false;
this.disconnect();
this.connect();
Expand Down

0 comments on commit b21f502

Please sign in to comment.