Am trying to integrate Websocket connection from the Android Kotlin application. The Websocket connection works fine when called from the browser. But when the Android application makes WS connection I receive the below error, however other HTTP REST APIs are working fine. I had enabled android:usesCleartextTraffic=”true” and network-security-config to allow clear traffic
AndroidManifest.xml
<application
android:supportsRtl="true"
android:usesCleartextTraffic="true"
android:networkSecurityConfig="@xml/network_security_config"
tools:targetApi="31">
network_security_config.xml
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">com.abc.def</domain>
<domain includeSubdomains="true">192.168.0.xx:9000</domain>
</domain-config>
</network-security-config>
Tried following all the solutions provided in stackoverflow.com, but nothing worked
user25534522 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.