How to access raspberry.local in my android application?
Asked Answered
T

1

6

I am running Django on my raspberry-pi, and I am using avahi-daemon to access my rpi on raspberrypi.local . On my Django I have made APIs for my android application to access via HTTP protocol. For example one of my http request url is: http://raspberrypi.local/api/getUserNames/

The problem is that android is not accessing this url on my local wifi network, i have confirmed that my android device and rpi are both connected to same wifi network, but still the http://raspberrypi.local is not working on android. While it works fine on my PC & MAC.

I tried to find the solution and went through many Q&A explaining about bonjour, mDNS, jmDNS, android-multicast. But all are either too confusing to implement or doesn't work. Please help me, I'm stuck for a while.

NOTE: on my Rpi the avahi-daemon is broadcasting itself as "_workstation._tcp." service-type

--

My Solution:

http://www.dodgycoder.net/2015/02/setting-up-bonjourzeroconfmdnsnsd.html

Android NSD (Network Service Discovery) solved my problem. I used only Discovery Listener and Resolve Listener to solve my purpose. I specifically used SERVICE_TYPE = "_workstation._tcp."; in order to search for raspberrypi.local with avahi-daemon

Thorley answered 13/1, 2017 at 5:47 Comment(0)
T
1

Android NSD (Network Service Discovery) solved my problem. I used only Discovery Listener and Resolve Listener to solve my purpose.

NOTE- You'll have to use SERVICE_TYPE = "_workstation._tcp."; in order to search for raspberrypi.local with avahi-daemon

here's link to the solution - http://www.dodgycoder.net/2015/02/setting-up-bonjourzeroconfmdnsnsd.html

Thorley answered 16/1, 2017 at 13:6 Comment(4)
This is really something else than was asked - while some systems may advertise a _workstation._tcp service, that's really quite distinct from an mDNS hostname which is what the question is about. In particular, this approach won't work for systems that don't advertise that.Rhombohedral
I posted the question too, it's about how to access the webapp hosted on a Rpi's port 80 on an android application. Using avahi-daemon (raspberrypi.local)Thorley
This may work for you, but it is not an answer to your original question - what you've done is change the raspberry pi to advertise a service and then resolved an instance of that service - you haven't actually looked up the mDNS host name, as was asked in the original question. Ironically, it looks like the underlying native tool Android uses behind the scenes can resolve hosts, but it doesn't seem to offer a public API to resolve anything but services.Rhombohedral
Actually, it is a sort of answer to me. RPi (with avahi, maybe +samba) advertises its name, other PCs can use it. Android, however, cannot. Unless one makes a some trick in the Android application. Sad, but an answer to me.... https://mcmap.net/q/1379971/-android-resolve-local-mdnsEllersick

© 2022 - 2024 — McMap. All rights reserved.