I am trying to resolve IPv4 and IpV6 from ".local" using multicast DNS and I tried https://github.com/posicks/mdnsjava but it unable to resolve required ipv4/ipv6. Alternatively, I found one app which work for me but have no idea how it works.
App Link : https://play.google.com/store/apps/details?id=com.dokoden.dotlocalfinder
Also I am trying to resolve ".local" using Linux Terminal -
Command used to resolve ipv4
avahi-resolve-host-name abc.local -4
Command used to resolve ipv6
avahi-resolve-host-name abc.local -6
and it resolved successfully.
I am tried same command in Android to resolve ".local" but getting Cannot run program "avahi-resolve-host-name": error=13, Permission denied
I am trying this piece of code in Android -
Process process = Runtime.getRuntime().exec("avahi-resolve-host-name abc.local -4");
BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()));
Log.d("OutPut",in.readLine());
Finally, I got success.
I resolved Ipv4 and Ipv6 using mdnsjava dependency i.e.
implementation "xyz.gianlu.mdnsjava:mdnsjava:2.2.1"
For resolving Ipv4 I use this code snippet
for (Record record : new Lookup(localName, Type.A, DClass.IN).lookupRecords()) {
if (record.getType() == Type.A) {
((ARecord) record).getAddress().getHostAddress();
}
}
Before writing this code snippet you have to put MuticastLock on connected Wifi using
WifiManager.MulticastLock multicastLoc = wifiManager.createMulticastLock("mDnsLock");
multicastLoc.setReferenceCounted(true);
multicastLoc.acquire();
and after getting ip release multicastLock.
For Ipv6 I used same Ipv4 code snippet only here the record type should be Type.AAAA in place of Type.A
This code works up to Android 10.
I am not 100% this will work, but as comment is was to large.
check the following permissions in your AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
Following links might be usefull:
How to get IP address and names of all devices in local network on Android
https://developer.android.com/guide/topics/connectivity/wifi-scan
https://github.com/stealthcopter/AndroidNetworkTools
Related
I don't Know The Problem
enter image description here
Check whether you have internet connection or not.
Check if you have <uses-permission android:name="android.permission.INTERNET" /> in your AndroidManifest.xml
If you are using emulator, make sure emulator has internet connection
ERROR: for 515f8b2ecd33_docker-bind_bind_1 Cannot start service bind: b'driver failed programming external connectivity on endpoint docker-bind_bind_1 (bc8836ceccc907c7ad0610e941b533c68f250c56cffcd4646e9171e7a330c9b3): Error starting userland proxy: listen tcp 0.0.0.0:53: bind: address already in use'
Comment out masqdns parts of the docker-compose.yaml file that you should have in virtual environment folder("Home/User/ve").
If the error still persist Please update your docker-compose.yaml file.
I'm trying to connect to Ant media webrtc server wss://abcd.com:1234/demoApp/websocket. However it always throws.
de.tavendo.autobahn.WebSocketReader: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
de.tavendo.autobahn.WebSocketWriter: Socket is closed
I'm using ant media webrtc framework sample android example and changing the URL. It worked fine with test server of antmedia
wss://test.antmedia.io:5443/demo1234/websocket(URL changed for security purposes)
However I was never able to connect to the main server. This is the code at android which I'm using to connect with server.
webRTCClient = WebRTCClient(this#LiveSessionActivity, this)
webRTCClient.setVideoRenderers(mLiveSessionBinding?.pipViewRenderer, mLiveSessionBinding?.localGLSurfaceView)
webRTCClient.init(ANT_MEDIA_URL, mLiveSessionViewModel?.streamKey, IWebRTCClient.MODE_PUBLISH, "null", intent)
Any help is much appreciated. Thanks!
It's known issue in v2.2.1. You need to set chain.pem file to Ant Media Server. Here are the instructions:
Copy chain.pem to conf.
sudo cp /etc/letsencrypt/live/your_domain/chain.pem /usr/local/antmedia/conf
PS: Please change your_domain to your domain address.
1- Add this line
http.ssl_certificate_chain_file=conf/chain.pem
after
http.ssl_certificate_file=conf/fullchain.pem
in /usr/local/antmedia/conf/red5.properties file.
2- Add this line
<entry key="SSLCertificateChainFile" value="${http.ssl_certificate_chain_file}" />
after
<entry key="SSLCertificateFile" value="${http.ssl_certificate_file}" />
in /usr/local/antmedia/conf/jee-container.xml file
I am trying to send post request to a website with port configured. http://example.com:8080/. When i send the request, it show some error
http.post('example.com:8080/apps/api.php', body: {'name': 'doodle', 'color': 'blue'}).then((response) {
print(response);
});
Unhandled Exception: SocketException: Failed host lookup: 'example.com' (OS Error: No address associated with hostname, errno = 7)
The port is ignored there. Is there any way i can do to fix this? Or is there any other http library that i can use?
This is probably not a port issue. Make sure you set the correct permissions in the Android manifest file (android/app/src/main/AndroidManifest.xml) to be able to make HTTP calls from your Android app:
<uses-permission android:name="android.permission.INTERNET" />
More details on that here and the official documentation from Android on permissions here.
If you have added this line
<uses-permission android:name="android.permission.INTERNET" />
at android/app/src/main/AndroidManifest.xml
then try restarting emulator or computer itself.
In my case, I restarted my laptop and it was fine. Most of the times restarting computer will solve the problems like this.
we are trying to connect to an ipv6 local server address. This is the code snippet
_st := IdHTTP1.Get('http://[fe80::a6ee:57ff:fe5c:7de6]:8000/reparti');
The issue is the following:
If we compile for Windows -> It works and we get the json response
if we compile for either Android or iOS -> we get
"socket error #22 invalid argument"
and no response and the server do not receive any request
What are we missing?
Thank you for the support
The IP address you are attempting to connect to is incomplete. It is missing the mandatory scope ID.