MQTT 서버에 연결하는 데 eclipse MQTT을 사용했습니다.연결이 끊어졌습니다 (32109) - java.io.EOFException
나는 성공적으로 서버에 연결할 수 있지만 내가 메시지를 게시 할 때, 나는 연결이
MSG를 잃은
이 오류 가지고 : 연결이
LOC를 잃었다 : java.io.EOFException
: 연결이 원인을 손실을 excep : 연결이 끊어졌습니다 (32109) - java.io.EOFException
검색했습니다. 하지만 난 어떤 진정한 답변을 찾을 수 없습니다!
private final String DEFAULT_HOST = "edge-mqtt.facebook.com";
private final int DEFAULT_PORT = 443;
public void connect(String protogle) throws Exception {
this.broker = protogle + "://"+ DEFAULT_HOST + ":" + DEFAULT_PORT;
this.mqttClient = new MqttClient(broker,getMqttClientId() ,new MemoryPersistence());
MqttConnectOptions connOpts = new MqttConnectOptions();
connOpts.setCleanSession(true);
connOpts.setKeepAliveInterval(MQTT_KEEPALIVE);
connOpts.setUserName(getMqttUsername());
connOpts.setPassword(getMqttPassword().toCharArray());
//connOpts.setMqttVersion(3);//some times it have an error
//connOpts.setSocketFactory(SSLTunnelSocketFactory.getInstance());
Logger.w("Connecting to broker: "+broker);
Logger.w("isConnected:"+mqttClient.isConnected());
try {
IMqttToken cn = mqttClient.connectWithResult(connOpts);
Logger.w("connected");
}catch (MqttException me){
System.out.println("reason "+me.getReasonCode());
System.out.println("msg "+me.getMessage());
System.out.println("loc "+me.getLocalizedMessage());
System.out.println("cause "+me.getCause());
System.out.println("excep "+me);
return;
}
this.mqttClient.setCallback(new MqttCallback() {
@Override
public void connectionLost(Throwable me) {
Logger.w("Connection lost");
System.out.println("msg "+me.getMessage());
System.out.println("loc "+me.getLocalizedMessage());
System.out.println("cause "+me.getCause());
System.out.println("excep "+me);
}
@Override
public void messageArrived(String s, MqttMessage mqttMessage) throws Exception {
Logger.w("message Arrived");
}
@Override
public void deliveryComplete(IMqttDeliveryToken iMqttDeliveryToken) {
Logger.w("deliverd--------");
try {
MqttDeliveryToken token = (MqttDeliveryToken) iMqttDeliveryToken;
String h = token.getMessage().toString();
Logger.w("deliverd message :"+h);
} catch (MqttException me) {
System.out.println("reason "+me.getReasonCode());
System.out.println("msg "+me.getMessage());
System.out.println("loc "+me.getLocalizedMessage());
System.out.println("cause "+me.getCause());
System.out.println("excep "+me);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
및 게시 방법 :
private void publish(String topic , String payload , int qosLevel) throws Exception {
Logger.w("start publishing :");
//payload = Helper.zlib_encode(payload);
topic = mapTopic(topic);
MqttMessage message = new MqttMessage();
message.setPayload(payload.getBytes("UTF-8"));
message.setQos(0);
mqttClient.publish(topic , message);
Logger.w("publised------------------");
}
출력 :
Connecting to broker: ssl://edge-mqtt.facebook.com:443
isConnected:false
connected
start publishing :
deliverd--------
publised------------------
deliverd message : //my message
Connection lost
msg : Connection lost
loc : Connection lost
cause : java.io.EOFException
excep : Connection lost (32109) - java.io.EOFException
내가 여기에 {
here,
here,
here, ...}
내 코드에 설립 일부 링크
Eclipse 파고 로그 :
에 대한============== Connection options ==============
CleanSession : true
SocketFactory : [email protected]
MqttVersion : 3
KeepAliveInterval : 60
ConTimeout : 30
UserName : . . .
SSLProperties : null
WillDestination : null
==========================================
2017-10-19 09:42:02,182 INFO [MQTT Call: Bahram091547759 ] [MqttConnectionResultHandler ] - insta connected
2017-10-19 09:42:02,187 INFO [JavaFX Application Thread ] [MqttEventHandler ] - About to resubscribe to all requested topics
2017-10-19 09:42:08,559 INFO [JavaFX Application Thread ] [MqttAsyncConnection ] - Publishing message on topic "k.,". Payload size = "3"
2017-10-19 09:42:08,739 ERROR [MQTT Rec: Bahram091547759 ] [MqttCallbackHandler ] - Connection insta lost
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.readMqttWireMess age(MqttInputStream.java:65)
at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:107)
... 1 more
브로커의 로그에 액세스하여 연결이 닫힌 이유를 확인할 수 있습니까? 내 첫 번째 추측은 당신이 사용하는 주제에 게시 할 수있는 권한이 없다는 것입니다. – hardillb
@ hardillb 아니오 로그를 확인하지 않습니다. 통나무가 어디 있니? 어떻게 확인할 수 있습니까? – b4hr4m
어떤 브로커를 사용하고 어떻게 설치했는지와 같은 더 많은 정보를 알지 못합니다. (이 세부 정보를 추가하려면 질문을 편집하십시오) – hardillb