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

Aishwary Dhare
  • 509
  • 1
  • 6
  • 18

1 Answers1

0

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

Aishwary Dhare
  • 509
  • 1
  • 6
  • 18
  • 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. – Chris Stratton Aug 12 '17 at 00:32
  • 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 (http://raspberrypi.local) – Aishwary Dhare Aug 19 '17 at 17:17
  • 2
    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. – Chris Stratton Aug 19 '17 at 20:27
  • 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://stackoverflow.com/questions/27547461/android-resolve-local-mdns – jaromrax Sep 13 '20 at 07:30