Closed jovanpreet closed 6 years ago
@jovanpreet,
I am using it with angular 6 without error. Latest version is 0.2.0
Try:
npm install xmpp-bosh-client@latest --save
If doesn't work, remove node_modules and package-lock.json then run "npm install" in your project folder.
Ensure that you have:
"xmpp-bosh-client": "^0.2.0"
in package.json dependency list.
Beginning with 0.2.0
, you have to call client.connect()
manually after constructing BoshClient
object.
const USERNAME = "username@example.com";
const PASSWORD = "bfwlfPRhJw2Vp0kOnglao0";
const URL = "https://www.example.com:5280/http-bind/";
const connection = new BoshClient(USERNAME, PASSWORD, URL);
connection.on("error", (e) => {
console.log("Error connecting");
console.log(e);
});
connection.on("online", () => {
console.log("Connected successfully ");
});
connection.on("ping", () => {
console.log(`Ping received at ${new Date()}`);
});
connection.on("offline", () => {
console.log("Is OFFLINE");
});
connection.on("stanza", (e) => {
console.log("Is stanza");
});
connection.connect(); // <- This is new from 0.2.0
If you have any problems open an issue or comment here.
Thanks for your feedback.
@kdcro101 I am also using Angular 6. I even tried with a new project and also the version is latest i.e. 0.2.0. But I am still facing issue. See the screenshot below.
@jovanpreet ,
How are you importing BoshClient
?
I just simply added import { BoshClient } from "xmpp-bosh-client";
in app.component.ts
and then all the code in ngOnInit()
.
I use it in specific way to compile it into single js
file using browserify to use in web worker.
I have just tried simple import into component into my project and everything works OK.
ng serve
OKng build --prod --aot
OKNow, that doesn't mean something is not wrong.
Can you post your tsconfig.json
?
Here you go
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom"
]
}
}
@jovanpreet,
I was able to reproduce error on new angular app.
Please update to 0.2.4
. Problem should be fixed now.
Let me know if you have problems again.
Thank you very much for your feedback.
If you have any problem, open issue.
Thanks bud working now.
@jovanpreet ,
Please update to 0.3.0.
There are some breaking changes.
For angular app import
shoud be:
import { BoshClient } from "xmpp-bosh-client/browser";
when using with Node.js import with:
import { BoshClient } from "xmpp-bosh-client/node";
i tried with nativescript angular and i got this error . I did like what jovanpreet did.
@weijyewang,
Default import is for nodejs.
For browser, use :
import { BoshClient } from "xmpp-bosh-client/browser";
Check README.md
Please, let me know how it went.
If you have problems, please, open issue.
Yeah i did just that and it does not work for me
import { BoshClient } from "xmpp-bosh-client/browser";
const USERNAME = "zinxer@cubichat";
const PASSWORD = "test123";
const URL = "http://13.229.218.180:5222";
and then in the component
ngOnInit(): void {
this.chats.forEach(chat => {
this.totalUnreadMessageFromFriends += chat.unreadMessages;
});
this.connection = new BoshClient(USERNAME, PASSWORD, URL);
debugger;
this.connection.on("error", (e) => {
console.log("Error event");
console.log(e);
});
this.connection.on("online", () => {
console.log("Connected successfully");
});
this.connection.on("ping", () => {
console.log(`Ping received at ${new Date()}`);
});
this.connection.on("stanza", (stanza) => {
console.log(`Stanza received at ${new Date()}`);
console.log(stanza);
});
this.connection.on("offline", () => {
console.log("Disconnected/Offline");
});
this.connection.connect();
// this.initConnection();
// this.registerClient();
}
I notice that the protocol is http:
instead of http
. is that normal?
@weijyewang ,
You have stated that you are using nativescript. I haven't tested module with it (or have any experience).
import { BoshClient } from "xmpp-bosh-client/node";
Hi @kdcro101 ,
I am working together with @weijyewang. As we are using NativeScript with Angular & TypeScript, the proper way for us to import is using import { BoshClient } from "xmpp-bosh-client/browser";
We are using OpenFire as our server and we have BOSH enabled.
I also tried node import, but it returned the following error.
@bclee92 ,
I have opened new issue for this problem. This issue is for separate and solved problem.
We will handle it from there.
Hi I got the following 2 errors when using your module with angular. even though I tried all the ways as above mentioned but still I am getting
ERROR in ./node_modules/xmpp-bosh-client/node/src/base.js Module not found: Error: Can't resolve 'http' in 'C:\Users\Venkatesh B\Desktop\mounika\chat\node_modules\xmpp-bosh-client\node\src'
ERROR in ./node_modules/xmpp-bosh-client/node/src/base.js Module not found: Error: Can't resolve 'https' in 'C:\Users\Venkatesh B\Desktop\mounika\chat\node_modules\xmpp-bosh-client\node\src' Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ Error from chokidar (C:): Error: EBUSY: resource busy or locked, lstat 'C:\hiberfil.sys' Error from chokidar (C:): Error: EBUSY: resource busy or locked, lstat 'C:\pagefile.sys' Error from chokidar (C:): Error: EBUSY: resource busy or locked, lstat 'C:\swapfile.sys
Hi I got the following 2 errors when using your module with angular. How can I resolve them.