2017-05-16 3 views
0

ich trie 3 일 이후로 WSS를 통해 SAP MQTT에 연결합니다 (wss : //iotmmsXXXXXXXXX.hana.ondemand.com/com.sap.iotservices.mms/v1/). api/ws/mqtt).WSS를 통해 MQTT가있는 SAP 서버에 연결할 수 없습니다.

저는 이것을 p12 클라이언트 인증서를 사용하고 있습니다.

하지만 핸드 셰이크 (핸드 셰이크 참조) 이후에 붙어 있습니다 (Wireshark 그림 참조). output 그리고 그가 시도 :

wireshark 10.XX.XX.XXX

내 IP

155.XX.XX.XXX입니다 난이 오류가있어 30 초 후에는 SAP IP

입니다 다시 연결하십시오. 여기

는 자료 :

const fs = require('fs'); 
const mqtt = require('mqtt'); 

// Parts of URL and Path 
const hcp_account_id = 'WWWWWWWWW'; 
const hcp_landscape_host = '.hana.ondemand.com' // this is used on PROD with Client Certificate Authentication 
const my_endpoint_url_path = '/com.sap.iotservices.mms/v1/api/ws/mqtt'; 

//Certificate 
const client_p12 = "./YYYYYYYY-YYYY-YYYY-YYYY-YYYYYYYYYYYY.p12"; 

// the following values need to be taken from the IoT Cockpit 
const device_id = 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'; 
const message_type_id_From_device = 'ZZZZZZZZZZZZZZZZZZZZ'; 

// for down- upstream communication 
var my_publish_topic = "iot/data/" + device_id; 
var my_subscription_topic = "iot/push/" + device_id; 

var my_endpoint = "iotmms" + hcp_account_id + hcp_landscape_host; 

var wsoptions = 
    { 
     host: my_endpoint, 
     port: 443, 
     pfx: fs.readFileSync(client_p12), 
     passphrase: 'AAAAA', 
     checkServerIdentity: false, 
     protocol: 'mqttv3.1', 
     protocolVersion: 13, 
     perMessageDeflate: true, 
     client_max_window_bits: true 
    } 

var options = 
    { 
     wsOptions: wsoptions, 
     clientId: device_id, 
     protocolId: 'MQIsdp', 
     protocolVersion: 3, 
     protocol: 'wss', 
     hostname: my_endpoint, 
     port: 443, 
     path: my_endpoint_url_path 
    } 

const mqttc = mqtt.connect(options); 

mqttc.subscribe(my_subscription_topic, 0); 

mqttc.on('connect',() => console.log('connected!')); 

mqttc.on('error', (msg) => console.log('error: ' + msg)); 

mqttc.on('offline', (msg) => console.log('offline: ' + msg)); 

mqttc.on('close', (msg) => console.log('close: ' + msg)); 

// message is Buffer 
mqttc.on('message', (topic, message) => console.log('message(' + topic + '): ' + message.toString())); 

답변

0

나는

function sendPacket (client, packet, cb) { 
    client.emit('packetsend', packet) 
    var result = false 
    try { 
    var buf = mqttPacket.generate(packet) 
    result = client.stream.write(buf) 
    } catch (err){ 
    client.emit('error', err) 
    result = false 
    } 
    if (!result && cb) { 
    client.stream.once('drain', cb) 
    } else if (cb) { 
    cb() 
    } 
} 
에 "MQTT/lib 디렉토리/client.js"에서 "sendPacket"방법을 chaning 그것을 해결 한