长连接修复

master V2.1.9
yujialong 7 months ago
parent 9953106b2f
commit cf67d8a099
  1. 25
      src/components/TestPanel.vue

@ -1187,16 +1187,16 @@ export default {
// websocket
// socket
open () {
console.log("socket连接成功");
// console.log("socket");
},
// socket
error () {
console.log("连接错误");
// console.log("");
},
//
getMessage (msg) {
console.log("==websocket接收数据==");
console.log(JSON.parse(msg.data));
// console.log("==websocket==");
// console.log(JSON.parse(msg.data));
const { content } = JSON.parse(msg.data)
// 1234-id
if (content == 1 && this.projectPermissions === 2) {
@ -1207,7 +1207,7 @@ export default {
},
// socket
close () {
console.log("socket已经关闭");
// console.log("socket");
},
// socket
initSocket ({ id, account }) {
@ -1227,6 +1227,8 @@ export default {
// let ws = new WebSocket(`ws://124.71.74.9:15674/ws`);
let ws = new WebSocket(`wss://python.occupationlab.com/ws`);
this.client = Stomp.over(ws);
this.client.heartbeat.outgoing = 0
this.client.heartbeat.incoming = 0
//
const headers = {
login: MQTT_USERNAME,
@ -1235,17 +1237,18 @@ export default {
//
this.client.connect(headers.login, headers.passcode, this.onConnected, this.onFailed, 'pyhost');
},
onConnected: function () {
onConnected () {
//
this.clientTopic = '/amq/queue/pythonQueue_' + this.accountId;
this.client.subscribe(this.clientTopic, this.responseCallback, this.onFailed);
},
onFailed: function (frame) {
onFailed (frame) {
console.log("MQ Failed: " + frame);
// this.$message.error('')
// this.client.reset().start();
this.connect()
},
//
responseCallback: function (frame) {
responseCallback (frame) {
const data = JSON.parse(frame.body)
console.log("接收信息:", data, typeof data, newmain, newmain.$emit);
@ -1262,7 +1265,7 @@ export default {
}
},
//
close: function () {
close () {
this.client.disconnect(function () {
console.log("已退出账号");
})
@ -1271,7 +1274,7 @@ export default {
//
heartbeatDetection () {
setInterval(async () => {
await this.$get(this.api.heartbeatDetectionRabbit)
// await this.$get(this.api.heartbeatDetectionRabbit)
await this.$get(this.api.heartbeatDetection)
}, 55 * 1000)
},

Loading…
Cancel
Save