Ionic 4 Cannot access ‘Client’ before initialization at Module.createCliention

1k Views Asked by At

I am using stanza in ionic 4 , after successful install when i tried to test the connection it throws me error like…

ionic 4 Cannot access ‘Client’ before initialization at Module.createClient

import * as XMPP from 'stanza';
export class StanzaTestPage implements OnInit {
  client: any;
  constructor() {
  }
  ngOnInit() {
      this.createConn();
  }
  createConn() {
    let that = this;
    this.client = XMPP.createClient({
      jid: 'testUser@testhost',
      password: 'Pass_123',
      transport: 'websocket',
      wsURL: 'ws://***:1234/websock',
      useStreamManagement: true
    });
    this.client.connect();
    this.client.enableKeepAlive(/* { interval: 30 } */);
    this.client.on('auth:failed', function (err) {
      console.log("auth:failed.......");
      console.log(err);
    });
    this.client.on('disconnected', function (err) {
      console.log("disconnected.......");
      console.log(err);
    });

    this.client.on('session:error', function (err) {
      console.log("session:error.......");
      console.log(err);

    });

    this.client.on('auth:success', function (con) {
      console.log("auth:success.......");
      console.log(con);

    });
    this.client.on('session:started', function () {
      console.log("Session Started.......");
      that.client.sendPresence();//sending our presense in server
    });
  }
}

enter image description here

0

There are 0 best solutions below