diff --git a/src/components/TestPanel.vue b/src/components/TestPanel.vue index 654984f..1017ddd 100644 --- a/src/components/TestPanel.vue +++ b/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) // 1赛事、2创业、3考核、4模型。-号拼接携带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) },