tcp 错误判断修改
This commit is contained in:
parent
494da52f37
commit
2119758411
@ -5,9 +5,9 @@
|
|||||||
"name": "default",
|
"name": "default",
|
||||||
"material": {
|
"material": {
|
||||||
"certpath": "C:\\Users\\93218\\.ohos\\config\\openharmony\\auto_ohos_default_subject-two_com.oh.dts.cer",
|
"certpath": "C:\\Users\\93218\\.ohos\\config\\openharmony\\auto_ohos_default_subject-two_com.oh.dts.cer",
|
||||||
"storePassword": "0000001A201E78D07D9BC954731E8031E587503BCABA403A7FF51995EF10FEAF0A0AEE7314A959E32BA1",
|
"storePassword": "0000001A1DDAA4ACBCE726491F94C3AF56A2540582DD64F1D58054FCE4F27EB1EA3AB9254BF5C318282B",
|
||||||
"keyAlias": "debugKey",
|
"keyAlias": "debugKey",
|
||||||
"keyPassword": "0000001ADA728F738FCA67EB2AE35E237F224EE342E5CE1591F417AB0E0CEFE20EE9585997B6D82B6CFB",
|
"keyPassword": "0000001AD378A9170F3E15A274CD444FCF00FAF0839F218288C28EC15366295413D9CB4926E710B7AEE8",
|
||||||
"profile": "C:\\Users\\93218\\.ohos\\config\\openharmony\\auto_ohos_default_subject-two_com.oh.dts.p7b",
|
"profile": "C:\\Users\\93218\\.ohos\\config\\openharmony\\auto_ohos_default_subject-two_com.oh.dts.p7b",
|
||||||
"signAlg": "SHA256withECDSA",
|
"signAlg": "SHA256withECDSA",
|
||||||
"storeFile": "C:\\Users\\93218\\.ohos\\config\\openharmony\\auto_ohos_default_subject-two_com.oh.dts.p12"
|
"storeFile": "C:\\Users\\93218\\.ohos\\config\\openharmony\\auto_ohos_default_subject-two_com.oh.dts.p12"
|
||||||
|
|||||||
@ -189,8 +189,11 @@ class TcpUtils {
|
|||||||
this.requestMap.delete(key)
|
this.requestMap.delete(key)
|
||||||
await this.socket.close()
|
await this.socket.close()
|
||||||
this.socket = socket.constructTCPSocketInstance()
|
this.socket = socket.constructTCPSocketInstance()
|
||||||
|
const fileUtil = new FileUtil(globalThis.context)
|
||||||
|
const data = await fileUtil.readFile(GlobalConfig.comoonfileWriteAddress + '/config/ipConfig.txt');
|
||||||
|
const result = JSON.parse(data)
|
||||||
await this.socket.connect({
|
await this.socket.connect({
|
||||||
address: { address: "172.37.55.191", port: 19998 }
|
address: { address: result.tcpOppositeIp, port: 19998 }
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
console.log("tcp request reconnect success", JSON.stringify(res))
|
console.log("tcp request reconnect success", JSON.stringify(res))
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
|
|||||||
@ -109,7 +109,7 @@ export default async function request<T>(req: any): Promise<T> {
|
|||||||
// reject(err)
|
// reject(err)
|
||||||
// })
|
// })
|
||||||
// })
|
// })
|
||||||
return tempRequest<T>(req)
|
// return tempRequest<T>(req)
|
||||||
if (!isError) {
|
if (!isError) {
|
||||||
return new Promise<T>((resolve, reject) => {
|
return new Promise<T>((resolve, reject) => {
|
||||||
console.log("[http request] url: " + req.url)
|
console.log("[http request] url: " + req.url)
|
||||||
@ -118,7 +118,7 @@ export default async function request<T>(req: any): Promise<T> {
|
|||||||
console.log("[http request] http request success")
|
console.log("[http request] http request success")
|
||||||
resolve(response)
|
resolve(response)
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
isError=true
|
isError = true
|
||||||
connection.getDefaultNet((error: any, data: any) => {
|
connection.getDefaultNet((error: any, data: any) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
console.error(`Failed Http. Code:${error.code}, message:${error.message}`);
|
console.error(`Failed Http. Code:${error.code}, message:${error.message}`);
|
||||||
@ -141,7 +141,7 @@ export default async function request<T>(req: any): Promise<T> {
|
|||||||
console.log("[http request] url: " + req.url)
|
console.log("[http request] url: " + req.url)
|
||||||
console.log("[http request] only tcp request start")
|
console.log("[http request] only tcp request start")
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
tcpRequest(req).then(res=> {
|
tcpRequest(req).then(res => {
|
||||||
console.log("[http request] only tcp request success")
|
console.log("[http request] only tcp request success")
|
||||||
resolve(res as T)
|
resolve(res as T)
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
@ -152,59 +152,53 @@ export default async function request<T>(req: any): Promise<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!isError) {
|
// if (!isError) {
|
||||||
return new Promise<T>((resolve, reject) => {
|
// return new Promise<T>((resolve, reject) => {
|
||||||
console.log("[http request] url: " + req.url)
|
// console.log("[http request] url: " + req.url)
|
||||||
console.log("[http request] tcp request start")
|
// console.log("[http request] tcp request start")
|
||||||
tcpRequest<T>(req).then((response) => {
|
// tcpRequest<T>(req).then((response) => {
|
||||||
console.log("[http request] tcp request success")
|
// console.log("[http request] tcp request success")
|
||||||
resolve(response)
|
// resolve(response)
|
||||||
}).catch((error) => {
|
// }).catch((error) => {
|
||||||
isError = true
|
// if (error.code === 2300007) {
|
||||||
// vs.playAudio({
|
// isError = true
|
||||||
// type: 1,
|
// }
|
||||||
// name: 'voice/PLCError.mp3'
|
// connection.getDefaultNet((error: any, data: any) => {
|
||||||
// })
|
// if (error) {
|
||||||
connection.getDefaultNet((error: any, data: any) => {
|
// console.error(`Failed Http. Code:${error.code}, message:${error.message}`);
|
||||||
if (error) {
|
// return;
|
||||||
console.error(`Failed Http. Code:${error.code}, message:${error.message}`);
|
// }
|
||||||
return;
|
// console.log("Http success" + JSON.stringify(data));
|
||||||
}
|
// });
|
||||||
console.log("Http success" + JSON.stringify(data));
|
// console.log("[http request] tcp request error: " + JSON.stringify(error))
|
||||||
});
|
// console.log("[http request] start http resend")
|
||||||
console.log("[http request] tcp request error: " + JSON.stringify(error))
|
// tempRequest<T>(req).then(response => {
|
||||||
console.log("[http request] start http resend")
|
// console.log("[http request] http resend success")
|
||||||
tempRequest<T>(req).then(response => {
|
// resolve(response as T)
|
||||||
console.log("[http request] http resend success")
|
// }).catch(err => {
|
||||||
resolve(response as T)
|
// TempLogger.error(JSON.stringify({
|
||||||
}).catch(err => {
|
// time: dateFormat(new Date()),
|
||||||
// vs.playAudio({
|
// error: JSON.stringify(error),
|
||||||
// type: 1,
|
// params: JSON.stringify(req)
|
||||||
// name: 'voice/PLCError.mp3'
|
// }))
|
||||||
// })
|
// console.log("[http request] http resend failed: " + JSON.stringify(err))
|
||||||
TempLogger.error(JSON.stringify({
|
// reject(err)
|
||||||
time: dateFormat(new Date()),
|
// })
|
||||||
error: JSON.stringify(error),
|
// })
|
||||||
params: JSON.stringify(req)
|
// })
|
||||||
}))
|
// } else {
|
||||||
console.log("[http request] http resend failed: " + JSON.stringify(err))
|
// console.log("[http request] url: " + req.url)
|
||||||
reject(err)
|
// console.log("[http request] only http request start")
|
||||||
})
|
// return new Promise((resolve, reject) => {
|
||||||
})
|
// tempRequest(req).then((response) => {
|
||||||
})
|
// console.log("[http request] only http request success")
|
||||||
} else {
|
// resolve(response as T)
|
||||||
console.log("[http request] url: " + req.url)
|
// }).catch(err => {
|
||||||
console.log("[http request] only http request start")
|
// console.log("[http request] only http request error")
|
||||||
return new Promise((resolve, reject) => {
|
// reject(err)
|
||||||
tempRequest(req).then((response) => {
|
// })
|
||||||
console.log("[http request] only http request success")
|
// })
|
||||||
resolve(response as T)
|
// }
|
||||||
}).catch(err => {
|
|
||||||
console.log("[http request] only http request error")
|
|
||||||
reject(err)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//xml格式转JSON
|
//xml格式转JSON
|
||||||
|
|||||||
@ -1,16 +1,15 @@
|
|||||||
-----BEGIN CERTIFICATE-----
|
-----BEGIN CERTIFICATE-----
|
||||||
MIICFDCCAZugAwIBAgIIbCabrHLc1nQwCgYIKoZIzj0EAwMwYzELMAkGA1UEBhMC
|
MIICFTCCAZugAwIBAgIIGq+f00ke04IwCgYIKoZIzj0EAwMwYzELMAkGA1UEBhMC
|
||||||
Q04xFDASBgNVBAoTC09wZW5IYXJtb255MRkwFwYDVQQLExBPcGVuSGFybW9ueSBU
|
Q04xFDASBgNVBAoTC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+GZpx/whBbTlB0O9qL5IKqk
|
aAAwZQIxANvofcfVoWsL2NZJtI1wpWSIJDTcgZCo09raKGJKx2TlYgh3nJkBzBEh
|
||||||
YMuXDxsAAjASc4/mVZ9n/o8XAV1CnPzLAP8hdZhTUTRY6vnf+5oKrl+VQWtsfmlT
|
IWwDsdUBZQIwI6ldAid/nCS8IcipHo8LmwJql8sIZ1BdRECQdkLK+yfzni/Kmy14
|
||||||
v4R8JxW/Pf0=
|
77svjX/mmH4f
|
||||||
-----END CERTIFICATE-----
|
-----END CERTIFICATE-----
|
||||||
|
843EBF354F774A955869BD3344B657552D16C547E46E1F6CEDCB79CEF80628A4
|
||||||
73706A370E90F2232DCA48943881E8AE44A27ADFBD6C25EE22CE13ED941EEE7C
|
|
||||||
Loading…
x
Reference in New Issue
Block a user