问题标签 [nsd]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
327 浏览

android - 即使不在同一个网络中,我们也可以从 Android 设备连接到 iPhone 吗?

我正在使用 wifi direct 和 NSD(网络服务发现)来传输文件。

  1. NSD:已创建服务的位置,可以扫描在同一网络中发布相同服务的其他设备。
  2. WiFi Direct:用于扫描附近没有网络的设备
  3. WiFi P2P网络服务发现:用于扫描其他设备提供相同服务的设备附近的服务(NSD+WiFi Direct)

根据要求,即使两者不在同一个网络中,我也需要为 iOS 设备提供兼容性。我知道 NSD 类似于 iOS 的 Bonjour 服务。但是当设备在同一个网络中时,这是可能的。

当两者不在同一个网络中时,有什么方法可以连接到 iPhone?

0 投票
2 回答
2525 浏览

android - errorCodes 对 Android NSD onResolveFailed() 意味着什么

Android Network Service Discovery为我们提供了一个onResolveFailed()回调,如下所示:

就我而言,我得到错误代码 3。

这些 erorCodes 代表什么,我在哪里可以找到指定的?

0 投票
1 回答
1350 浏览

android - 使用 android NSD 发现网络中的所有服务

我正在尝试使用以下方法查找网络中的所有服务:

但您必须定义 SERVICE_TYPE 例如:

所以它会发现所有使用 tcp 的 http 服务,但它不会同时发现 https 服务或任何其他类型的服务

我如何设置所有这些以使用 tcp 查找任何服务?

先感谢您。

0 投票
3 回答
4003 浏览

android - Android 网络服务发现示例 Nsdchat 不工作

我正在尝试使用官方的 android NSDchat 示例在连接到同一个 wifi 网络的两部 android 手机之间进行通信。将项目导入 Eclipse 后,我只将目标 sdk 更改为 api 级别 22 而不是 16。我在各种设备上尝试了该应用程序,如 api 18 的三星设备、api 21 的 htc 设备、api 21 的华硕设备等。对其中一些有效,对另一些无效,而且它在不同的设备上给出不同的错误。运行代码时出现空指针异常,当我重新启动设备时,错误消失了。此外,演示应用程序是否不支持更高的 api 级别,或者在运行之前是否应该对该代码进行任何更改?

0 投票
1 回答
131 浏览

android - android上的网络服务发现是否允许首次连接后自动连接(持久连接)?

我想在第一次连接发生后在任意两台设备之间建立自动连接。nsd on android 提供这样的功能吗?我已经在 android http://developer.android.com/training/connect-devices-wireless/nsd.html上引用了这个 nsd 链接 另外,我们可以在同一个网络上发现多个设备,但是我们可以在上面连接多个设备同一个网络?

0 投票
1 回答
538 浏览

android - Android NSD:模拟器上没有发生服务注册

我想通过模拟器应用注册一个 NSD 服务。模拟器在连接到本地网络的 linux ubuntu 机器上运行。

我按照此处列出的说明进行操作。

当我在我的 Nexus 设备上运行应用程序时,我可以注册服务。我已将 nexus 设备连接到同一本地网络。我正在使用avahi-browse --all命令来检查注册的服务。当我在 nexus 设备上运行应用程序后运行此命令时,我会获得新注册服务的条目。

下面是命令运行的输出:

这里的“NsdChatEmulator_3”是服务的名称。

但是当我在模拟器上运行同一个应用程序时,它正在运行但服务没有注册。

有人知道在模拟器上使用 NSD 有什么问题吗?

0 投票
0 回答
616 浏览

android - NsdManager 注册失败

问题: 简短描述: 我正在尝试注册对我的 PC 可见的服务和端口,以便以后连接到 PC 应用程序。这段代码没有注册服务,我不知道为什么,我只知道当它通过安卓监视器在我的手机上运行时,我使用记录器告诉我注册失败。

更长的描述: 我一直在尝试构建一个简单的应用程序,它将为我的 PC 提供来自我的 Android 手机的信息。我不熟悉网络编程,但从我的研究中我了解到,如果我使用 android 的 NsdManager,我将能够为我正在开发的 PC 应用程序创建一个在我的网络上运行的服务,以使用“套接字编程”连接到。我一直在尝试使用 NsdManager 来注册此服务(如果他们是在我的手机上启动在我的网络上运行的服务以通过 PC 连接到的更好的方法,那么将不胜感激。

请求帮助: 很高兴知道: 1. 开始开发与我稍后将开发的 PC 应用程序“配对”的 Android 应用程序的最佳方式是什么?2. 注册服务的 NsdManager 方法是否适用于此?3. 有没有办法捕捉到为什么这个服务无法注册的错误码?4. 对开始 android 网络开发有什么有用的资源、库、提示或技巧吗?我是这个开发小节的新手,正在寻找这些东西。

代码:

非常感谢您的时间和帮助!

0 投票
2 回答
5319 浏览

android - Android, NSD/DNS-SD: NsdManager unreliable discovery and IP resolution

In the course of the last weeks, Android's NSD implementation is making me go mad:

From a user's point of view, the following problems arise:

  • Devices discover each other in a completely non-deterministic fashion. If I launch my NsdManager-based app, it works more or less if only two devices are involved. If a third device joins, it will seldomly discover the first two, and the first two will not see the third. If I exit the apps (they gracefully unregister the NSD listeners) and restart them in a different order, the discovery pattern is not exactly the same, but similar.

  • In my home network, the IP resolution of the discovered devices basically works as expected. At work, sometimes even when only using two devices (A and B), device A will resolve device B's service with A's IP address and B's port and vice-versa. So somehow the IP address and service name seem to get mixed up at a lower level (probably the NsdManager).

I've now filed a bug report on Google code for this (https://code.google.com/p/android/issues/detail?id=201314&thanks=201314&ts=1455814995). I'm posting this here too in hope to get more feedback; maybe I got something in my Nsd helper class wrong.

First of all, after endless debugging, I have now found hints in the logcat that Android's underlying NsdService itself might be malfunctioning, while MDnsDS seems to work correctly. But I'm unsure...

Here's some log output that illustrates the problem (some messages filtered for readability):

Some notes on the context:

  • My NSD service type is _tusync._tcp.
  • I create unique service names for all nodes in the format TuSync-0.[local port number] to prevent naming conflicts and ease debugging.
  • In this test scenario, there are three devices. The logging device's IP is 10.0.0.4, port 57392.

The log shows, that the underlying MDnsDS daemon correctly discovers and resolves all nodes. However, the NsdService above does not propagate the resolution for all of them. There seems to be an ID conflict at 16:57:04.627, where both of the device's peers (TuSync-0.36230 and TuSync-0.60493) get assigned an internal ID of 107 (if I interpret the mechanisms correctly just by looking at the logs). The discoveryListener I registered with the NsdManager is notified upon the discovery of both nodes, however, resolving only works for one of them, the other triggers an error:

I have also experienced additional cases where, after the NsdService emits a "SERVICE_FOUND Raw" message in the logs, my discovery listener is not notified. An exemplary log (heavily filtered; same test setup as above):

In this case, the discovered peer 10.0.0.5 (port 36230) triggers no discoveryListener notification. After the last log message, nothing happens. So my logging node 10.0.0.4 only discovered one other peer, 10.0.0.6:60493.

The low amount of similar bug reports makes me wonder if I'm the only one with these problems or if the NsdManager is completely unstable and no-one uses it anyway?

For reference, here is the code of my helper class - it is similar to the Android NSD chat tutorial, but I tried to improve it because of some other bugs the tutorial seems to provoke.

Note, that I even implemented a semaphore that can be set to 1 to prevent resolving multiple services in parallel, as somebody else reported problems with parallel resolution. However, setting it to 1 does not work, as sometimes the ongoing resolution does neither succeed nor fail; which causes the semaphore not to be released and the NsdManager thread to get permanently stuck at the next resolve request.

Is anyone else experiencing such problems? I'd be glad if also people who are successfully employing the NsdManager would comment - that would at least mean I'm facing a problem I can fix :)

I already considered giving up on NSD and implementing my own broadcast/multicast discovery mechanism. This could theoretically be a breeze, but I've read that multicast on Android is a PITA too, because of some devices preventing it...

0 投票
1 回答
2891 浏览

android - 如何在android中获取连接到我的Wi-Fi的设备列表?

我需要获取连接到我已连接的 Wi-Fi 的设备列表(以及它们的可能详细信息)。我不需要与他们中的任何人联系和聊天。我正在浏览这个链接http://developer.android.com/training/connect-devices-wireless/wifi-direct.html#fetch

wifi p2p 连接是否适合我的要求?如何在没有 Wifi-Direct 功能的设备上获取已连接设备的列表?我的应用程序是否需要安装在其他设备上才能使用 wifi p2p 连接?我已经尝试过这个https://github.com/rorist/android-network-discovery但它在应用程序启动时强制关闭。我在 Playstore 上看到过类似Fing的应用程序。他们是怎么做到的?

请帮我。提前致谢。

0 投票
1 回答
2809 浏览

android - 使用网络服务发现注册失败,错误代码为 0 。

每当我使用 registerService 函数时,它都会给出代码错误 0 的异常。 1) 我正在创建一个本地聊天服务应用程序,我需要在其中进行本地服务广播,并且在这样做的同时,无论我做什么,我都被卡住了,注册总是以错误代码 0 失败。我在 onResume() 或 onPause() 块中没有多个注册实例。2) Logcat 只显示

尝试完成输入事件,但输入事件接收器已被释放。

每当我点击右上角的注册服务按钮时。

这是我的代码: