Dear Guys,
(new to ionic…)
I try to get WebSocket work in an ionic2 Android app.
In browser mode it is working fine.
I installed https://github.com/knowledgecode/WebSocket-for-Android and followed all the instructions:
- installed cordova-plugin-whitelist
- set a Content-Security-Policy (CSP)
- set config.xml:
< access origin=""/>
< allow-intent href="ws:///:"/>
< allow-intent href=“wss:///:*”/>
but there is no connection to my server when i test with ionic run android
connect(){
this.ws = new WebSocket(“ws://192.168.178.170:8000”);
this.ws.onopen = () => {
console.log('open');
};
this.ws.onmessage = (event) => {
console.log('new message: ' + event.data);
this.messages.push(event.data);
};
this.ws.onerror = () => {
console.log('error occurred!');
};
this.ws.onclose = (event) => {
console.log('close code=' + event.code);
this.connect();
};
Did i missed something?