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": "*"
    }
  ]
}
asked 5 years ago396 views
1 Answer
0

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

AWS IoT does not support publishing and subscribing with QoS 2.
answered 5 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions