优化tcp超时时间
This commit is contained in:
parent
2a588d5d7c
commit
7dfc959aa2
@ -109,12 +109,6 @@ export async function writeObjectOut(params, filePath?: string): Promise<WR> {
|
||||
await fileUtil.initFolder(filePath);
|
||||
fileUtil.editFile(`${filePath}/wuxi_exam_data.txt`, JSON.stringify(temp) + `\n`);
|
||||
}
|
||||
// const {code} = temp;
|
||||
// if(code == '2300007' || code == '2300028'){
|
||||
// return await writeObjectOut(params,filePath)
|
||||
// }else{
|
||||
// return temp
|
||||
// }
|
||||
return temp
|
||||
}
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@ export default class TcpClient {
|
||||
//重连次数
|
||||
private folderPath
|
||||
|
||||
private tcp: any = null
|
||||
private tcp: socket.TCPSocket = null
|
||||
|
||||
constructor(tcplocalIp: string, tcplocalIpPort: string, tcpOppositeIp: string, tcpOppositePort: string) {
|
||||
this.localIp = tcplocalIp
|
||||
@ -65,7 +65,7 @@ export default class TcpClient {
|
||||
this.tcp.connect({
|
||||
address: {
|
||||
address: this.oppositeIp, port: Number(this.oppositeIpPort), family: 1
|
||||
}, timeout: 6000
|
||||
}, timeout: 1000 * 15
|
||||
}).then(() => {
|
||||
this.tcp.setExtraOptions({
|
||||
keepAlive: true,
|
||||
@ -148,7 +148,7 @@ export default class TcpClient {
|
||||
|
||||
offTcp(callback) {
|
||||
console.log(TAG, 'tcpofff')
|
||||
this.tcp.off('testTagofmessg', callback);
|
||||
this.tcp.off('message', callback);
|
||||
}
|
||||
|
||||
closeTcp(callback) {
|
||||
|
||||
@ -342,9 +342,6 @@ export default struct SignDisplayCom {
|
||||
}
|
||||
|
||||
async aboutToAppear() {
|
||||
// const fileUtil = new FileUtil(globalThis.context)
|
||||
// const data = await fileUtil.readFile(GlobalConfig.comoonfileWriteAddress + '/config/ipConfig.txt')
|
||||
// this.udplocalIp=JSON.parse(data)?.udplocalIp||'192.168.7.170'
|
||||
this.ratio = this.ratio * (this.scaleNum || 1);
|
||||
const {showBack,getSignal} = this
|
||||
|
||||
|
||||
@ -607,7 +607,7 @@ export default class Judge {
|
||||
const temp = await writeObjectOut(data, filePath);
|
||||
console.log("wzj", JSON.stringify(temp))
|
||||
//断网&网络超时次数计算
|
||||
if (temp.code == 2300007 || temp.code == 2300028) {
|
||||
if (temp.code != 1) {
|
||||
this.disConnectNum += 1;
|
||||
if (this.disConnectNum < 5) {
|
||||
return await this.sendWriteObjectOut(data, filePath)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user