7001 端口迁移,改为 7071/7072 故障转移发送

This commit is contained in:
liufumingren 2026-08-28 20:00:31 +08:00
parent dd39b4d287
commit f35b201810
2 changed files with 35 additions and 10 deletions

View File

@ -335,18 +335,26 @@ class Wms extends Api
$tmp_code = base64_encode(json_encode(["uuid"=>$uuid]));
$gzt->tmp_code = $tmp_code;
$gzt->save();
$url="http://127.0.0.1:7001/tool/backMsg";
// 端口故障转移:优先 7071/7072 保活端口,7001 作兜底
$ports = ['7071','7072','7001'];
$options = [];
$requsetData = [
'sid'=>$sid,
'method'=>"binded",
'data'=>$tmp_code
];
$options = [];
$urlEncodedString = http_build_query($requsetData);
$req = Http::sendRequest($url, $urlEncodedString, 'POST', $options);
\think\Log::error("[gzt_bind] binded 请求结果: " . json_encode($req, JSON_UNESCAPED_UNICODE));
$req = ['ret'=>false];
foreach ($ports as $port) {
$url = "http://127.0.0.1:{$port}/tool/backMsg";
$req = Http::sendRequest($url, $urlEncodedString, 'POST', $options);
\think\Log::error("[gzt_bind] binded 请求结果(port={$port}): " . json_encode($req, JSON_UNESCAPED_UNICODE));
if($req['ret']){
break;
}
}
if(!$req['ret']){
\think\Log::error("[gzt_bind] binded 发送失败: " . json_encode($req, JSON_UNESCAPED_UNICODE));
\think\Log::error("[gzt_bind] binded 发送失败,所有端口均不可用");
}
if($sid2){
$requsetData = [
@ -355,10 +363,17 @@ class Wms extends Api
'data'=>""
];
$urlEncodedString = http_build_query($requsetData);
$req = Http::sendRequest($url, $urlEncodedString, 'POST', $options);
\think\Log::error("[gzt_bind] cheakBind 请求结果: " . json_encode($req, JSON_UNESCAPED_UNICODE));
$req = ['ret'=>false];
foreach ($ports as $port) {
$url = "http://127.0.0.1:{$port}/tool/backMsg";
$req = Http::sendRequest($url, $urlEncodedString, 'POST', $options);
\think\Log::error("[gzt_bind] cheakBind 请求结果(port={$port}): " . json_encode($req, JSON_UNESCAPED_UNICODE));
if($req['ret']){
break;
}
}
if(!$req['ret']){
\think\Log::error("[gzt_bind] cheakBind 发送失败: " . json_encode($req, JSON_UNESCAPED_UNICODE));
\think\Log::error("[gzt_bind] cheakBind 发送失败,所有端口均不可用");
}
}
$this->success('绑定成功');

View File

@ -3701,8 +3701,18 @@ class Wms extends Frontend
'POSTNUM'=>$r["POSTNUM"],
'method'=>'picks'
];
$url="http://127.0.0.1:7001/test";
$res = Http::post($url,$requsetData);
// 端口故障转移:优先 7071/7072 保活端口,7001 作兜底
$res = '';
foreach (['7071','7072','7001'] as $port) {
$url = "http://127.0.0.1:{$port}/test";
$res = Http::post($url,$requsetData);
if ($res !== '') {
break;
}
}
if ($res === '') {
\think\Log::error("[getcar2] picks 通知发送失败,所有端口均不可用: " . json_encode($requsetData, JSON_UNESCAPED_UNICODE));
}
}
}
if(!$data2){