IoT Core Can Connect, Can Subscribe, Can Not Publish

0

I have a java app which can connect and subscribe to IoT Core but disconnects if I try to publish. This same app connects, subscribes and publishes to a stand alone broker running in the cloud but will not publish to IoT Core. Additionally using the same certificate and Id I can publish using the MQTT.fx client. I have seen multiple similar questions but haven't found any solutions. Hopefully someone can help?

Code is:

public void publish(String topic,String message) {
	    MqttMessage sPayload = new MqttMessage(message.getBytes());
	    sPayload.setRetained(false);
	    sPayload.setQos(2);
	    try {	
	        sampleClient.publish(topic, sPayload);
		} catch (MqttException e) {
			e.printStackTrace();
            }
	}

Error is:

Connection lost (32109) - java.io.EOFException
	at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:146)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.io.EOFException
	at java.io.DataInputStream.readByte(Unknown Source)
	at org.eclipse.paho.client.mqttv3.internal.wire.MqttInputStream.readMqttWireMessage(MqttInputStream.java:61)
	at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:107)
	... 1 more

Policy is:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": "iot:*",
      "Resource": "*"
    }
  ]
}
gefragt vor 5 Jahren402 Aufrufe
1 Antwort
0

Well, turns out I'm a dummy who needs to RTFM.

AWS IoT does not support publishing and subscribing with QoS 2.
beantwortet vor 5 Jahren

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen