فهرست منبع

websock报错重新连接

lihongxiao 1 سال پیش
والد
کامیت
ce69032d0b
3فایلهای تغییر یافته به همراه12 افزوده شده و 3 حذف شده
  1. 2 2
      config/dev.env.js
  2. 9 0
      src/utils/websocket.js
  3. 1 1
      src/views/Home.vue

+ 2 - 2
config/dev.env.js

@@ -5,7 +5,7 @@ const prodEnv = require('./prod.env')
 module.exports = merge(prodEnv, {
   NODE_ENV: '"development"',
   ENV_CONFIG: '"dev"',
-  // BASE_URL: '"https://test.baoxianzhanggui.com/web-api"',//测试服务器
+  BASE_URL: '"https://test.baoxianzhanggui.com/web-api"',//测试服务器
   // BASE_URL:'"https://sxzgkj.baoxianzhanggui.com/web-api"',//正式服务器
   // BASE_URL:'"https://sxzgkj.baoxianzhanggui.com/web-api"'//正式服务器
   // BASE_URL: '"http://192.168.0.115:8080/"', //凯森
@@ -17,7 +17,7 @@ module.exports = merge(prodEnv, {
   // BASE_URL: '"http://192.168.1.101:8080/"',
   // BASE_URL: '"http://192.168.0.250:8080/"',//
   //  BASE_URL: '"http:///192.168.0.103:8080/"',//霍续亮
-  BASE_URL: '"http://192.168.0.52:8080/"',//贺礼霄
+  // BASE_URL: '"http://192.168.0.52:8080/"',//贺礼霄
   // BASE_URL: '"http:///192.168.0.55:8080/"',// 董鑫
   CONSOLE_BASE_URL: '"http://localhost:8080/"', //控制台测试服务器
   // CONSOLE_BASE_URL: '"https://test.baoxianzhanggui.com/console-api"' //控制台正式服务器

+ 9 - 0
src/utils/websocket.js

@@ -24,6 +24,15 @@ export function websocketSend (agentData) {
       websock.send(JSON.stringify(agentData))
     }
     if (websock.readyState === websock.CLOSED) { // websock.CLOSED = 3
+      let userId = sessionStorage.getItem("user");
+      let data = {
+        ...agentData,
+        userId,
+      };
+      sendWebsocket(
+        `${process.env.SOCKET_Url}/pcWebsocket/${userId}`,
+        data
+      );
       console.log('websock.readyState=3')
       // Message.error('ws连接异常,请稍候重试')
       errorCallback()

+ 1 - 1
src/views/Home.vue

@@ -51,7 +51,7 @@ export default {
       // // }, 2 * 60 * 60000); // 两个小时
        }, 19 * 60000); // 19分钟
       // }, 20 * 60000); // 半小时
-    // }, 1000); // 一秒
+    // }, 5000); // 一秒
 
   }