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": "*"
    }
  ]
}
질문됨 5년 전402회 조회
1개 답변
0

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

AWS IoT does not support publishing and subscribing with QoS 2.
답변함 5년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠