gpt4 book ai didi

android - Android 上的 MqttException

转载 作者:行者123 更新时间:2023-11-30 04:45:38 26 4
gpt4 key购买 nike

我一直在关注Dale Lane's blog通过我的 Android 项目访问 Mosquitto,但我停留在第一步。这是日志的相关部分:

02-24 20:43:17.324: WARN/System.err(316): com.ibm.mqtt.MqttException
02-24 20:43:17.534: WARN/System.err(316): at com.ibm.mqtt.MqttBaseClient.doConnect(Unknown Source)
02-24 20:43:17.534: WARN/System.err(316): at com.ibm.mqtt.MqttBaseClient.connect(Unknown Source)
02-24 20:43:17.534: WARN/System.err(316): at com.ibm.mqtt.MqttClient.connect(Unknown Source)
02-24 20:43:17.534: WARN/System.err(316): at com.ibm.mqtt.MqttClient.connect(Unknown Source)
02-24 20:43:17.534: WARN/System.err(316): at com.push.MQTTService.connectToBroker(MQTTService.java:665)
02-24 20:43:17.584: WARN/System.err(316): at com.push.MQTTService.handleStart(MQTTService.java:294)
02-24 20:43:17.584: WARN/System.err(316): at com.push.MQTTService.onStartCommand(MQTTService.java:210)
02-24 20:43:17.594: WARN/System.err(316): at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3053)
02-24 20:43:17.594: WARN/System.err(316): at android.app.ActivityThread.access$3600(ActivityThread.java:125)
02-24 20:43:17.594: WARN/System.err(316): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2096)
02-24 20:43:17.594: WARN/System.err(316): at android.os.Handler.dispatchMessage(Handler.java:99)

02-24 20:43:20.107: WARN/System.err(316): at com.ibm.mqtt.MqttBaseClient.doConnect(Unknown Source)
02-24 20:43:20.107: WARN/System.err(316): at com.ibm.mqtt.MqttBaseClient.connect(Unknown Source)
02-24 20:43:20.114: WARN/System.err(316): at com.ibm.mqtt.MqttClient.connect(Unknown Source)
02-24 20:43:20.124: WARN/System.err(316): at com.ibm.mqtt.MqttClient.connect(Unknown Source)
02-24 20:43:20.124: WARN/System.err(316): at com.push.MQTTService.connectToBroker(MQTTService.java:665)
02-24 20:43:20.124: WARN/System.err(316): at com.push.MQTTService.access$6(MQTTService.java:658)
02-24 20:43:20.124: WARN/System.err(316): at com.push.MQTTService$NetworkConnectionIntentReceiver.onReceive(MQTTService.java:883)

02-24 20:43:20.274: WARN/System.err(316): Caused by: java.net.ConnectException: /127.0.0.5:1883 - Connection refused
02-24 20:43:20.304: WARN/System.err(316): at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:254)
02-24 20:43:20.344: WARN/System.err(316): at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:533)
02-24 20:43:20.344: WARN/System.err(316): at java.net.Socket.connect(Socket.java:1055)
02-24 20:43:20.344: WARN/System.err(316): at com.ibm.mqtt.j2se.MqttJava14NetSocket.<init>(Unknown Source)
02-24 20:43:20.344: WARN/System.err(316): at com.ibm.mqtt.j2se.MqttJavaNetSocket.setConnection(Unknown Source)
02-24 20:43:20.376: WARN/System.err(316): at com.ibm.mqtt.Mqtt.tcpipConnect(Unknown Source)

02-24 20:47:17.677: DEBUG/SntpClient(65): request time failed: java.net.SocketException: Address family not supported by protocol

Dale 代码的“connectToBroker()”方法抛出异常:

mqttClient.connect("_unique_client_id", true, (short) 2000);     //tried many permutations

我在与客户端相同的机器上运行 Mosquitto 代理。我可以通过示例中提供的 IA92 客户端向代理发布/订阅。我还可以通过具有相同服务参数的简单 Java 项目进行连接。

非常感谢!

最佳答案

谢谢戴尔,我只需要将本地主机地址更改为 10.0.2.2,其余一切顺利。

关于android - Android 上的 MqttException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5046092/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com