Websocket connection problem in Android 9+



Paolo Lops

hi David,

why if i make and android app with web socket i'm not able to connect to the server ?

i use a non secure web socket.

i have try also

but with no success?

all is ok if i run the app in chrome browser , but when i compile it is android it is not working the error code is 1006

please help me!

David Esperalta

Hello Paolo,

It's quite rare... please, read this answer in StackOverflow. Maybe you can start to implement an error event for the websocket, so maybe you can get more information about the error.

On the other hand, maybe you can use the WebSocket control of AB. We use this control for the chat of certain app for Android and iOS and works very well in that platforms and also in browsers.

On the other hand, note the Android version... Android 9 and beyond don't allows non secure connections... except if we explicitly enable it in the app manifest file.



Paolo Lops
Perfect David, it works correctly also in android 9 with manifest directive

David Esperalta

Hello Paolo,

Glad to know that you got it. :-)



David Esperalta

Hello to all,

Just to mention that, from some releases ago, we can made changes in the "AndroidManifest.xml" file using the app options -> Cordova -> Configuration -> Extra XML, so we can place a code like the below in the referred option:

By doing that we are allowing clear (non secure) connections in Android 9+. This include HTTP but also WS (WebSocket) connections.

P.S. The above is valid for the previous AB generation and also for the current generation of the product.



Everybody can read the DecSoft support forum for learning purposes, however only DecSoft customers can post new threads. Purchase one or more licenses of some DecSoft products in order to give this and other benefits.