9100端口无法连接问题(重启wda),打印无法获取设备token的日志
parent
40ba86aff5
commit
d5f77b7295
|
@ -18,6 +18,7 @@ import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -163,18 +164,20 @@ public class IosScreenResponseThread extends ImageScreenResponse {
|
||||||
|
|
||||||
//有后端会话则给后端推送屏幕图片
|
//有后端会话则给后端推送屏幕图片
|
||||||
if (!CollectionUtils.isEmpty(webSessions)) {
|
if (!CollectionUtils.isEmpty(webSessions)) {
|
||||||
for (Session webSession : webSessions) {
|
Iterator<Session> iterator = webSessions.iterator();
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
Session webSession = iterator.next();
|
||||||
if (webSession.isOpen()) {
|
if (webSession.isOpen()) {
|
||||||
if (sendDeviceStatus) {
|
if (sendDeviceStatus) {
|
||||||
Map<String, Object> result = new HashMap<>();
|
Map<String, Object> result = new HashMap<>();
|
||||||
result.put(ResponseCmd.DeviceStatus.STATUS, ResponseCmd.DeviceStatus.CONNECTED);
|
result.put(ResponseCmd.DeviceStatus.STATUS, ResponseCmd.DeviceStatus.CONNECTED);
|
||||||
SessionUtils.sendMessageInitiative(webSession, ResponseCmd.DEVICE_STATUS, phone.getUdid(), result, "设备连接失败");
|
SessionUtils.sendMessageInitiative(webSession, ResponseCmd.DEVICE_STATUS, deviceId, result, "设备连接失败");
|
||||||
sendDeviceStatus = false;
|
sendDeviceStatus = false;
|
||||||
}
|
}
|
||||||
SessionUtils.sendBinary(webSession, rawImageFileByteArray);
|
SessionUtils.sendBinary(webSession, rawImageFileByteArray);
|
||||||
} else {
|
} else {
|
||||||
logger.warn("推送到web端的session已经断开,sessionId:{}",webSession.getId());
|
logger.warn("推送到web端的session已经断开,sessionId:{}",webSession.getId());
|
||||||
//todo:操作一下,去掉webSessions里面的无效session
|
iterator.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,6 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -67,11 +66,6 @@ public class MacIosDeviceInitThread extends IosDeviceInitThread {
|
||||||
if (xctestPath == null) {
|
if (xctestPath == null) {
|
||||||
throw new IllegalStateException("未准备好iOS " + productMainVersion + "的xctest");
|
throw new IllegalStateException("未准备好iOS " + productMainVersion + "的xctest");
|
||||||
}
|
}
|
||||||
File logDir = new File(UpperComputerManager.getInstance().getApplicationPath() + "/wdaLog");
|
|
||||||
if (!logDir.exists()) {
|
|
||||||
logDir.mkdirs();
|
|
||||||
}
|
|
||||||
logFileName = logDir.getAbsolutePath() + "/" + "WDA-" + appleDevice.getConnectionDetail().serialNumber + "-" + getLogFileNameDateTime() + ".log";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -89,6 +83,7 @@ public class MacIosDeviceInitThread extends IosDeviceInitThread {
|
||||||
"id=" + appleDevice.getConnectionDetail().serialNumber
|
"id=" + appleDevice.getConnectionDetail().serialNumber
|
||||||
);
|
);
|
||||||
processBuilder.redirectErrorStream(true);
|
processBuilder.redirectErrorStream(true);
|
||||||
|
while (!isInterrupted()) {
|
||||||
try {
|
try {
|
||||||
process = processBuilder.start();
|
process = processBuilder.start();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
@ -96,18 +91,24 @@ public class MacIosDeviceInitThread extends IosDeviceInitThread {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
FileOutputStream logOutput = null;
|
FileOutputStream logOutput = null;
|
||||||
|
File logDir = new File(UpperComputerManager.getInstance().getApplicationPath() + "/wdaLog");
|
||||||
|
if (!logDir.exists()) {
|
||||||
|
logDir.mkdirs();
|
||||||
|
}
|
||||||
|
logFileName = logDir.getAbsolutePath() + "/" + "WDA-" + appleDevice.getConnectionDetail().serialNumber + "-" + getLogFileNameDateTime() + ".log";
|
||||||
try {
|
try {
|
||||||
logOutput = new FileOutputStream(logFileName);
|
logOutput = new FileOutputStream(logFileName);
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
logger.error("尝试创建独立日志文件时发生异常", e);
|
logger.error("尝试创建独立日志文件时发生异常", e);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
BufferedReader bufferReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
InputStreamReader inputStreamReader = null;
|
||||||
do {
|
BufferedReader bufferReader = null;
|
||||||
|
String line = null;
|
||||||
try {
|
try {
|
||||||
String line = bufferReader.readLine();
|
inputStreamReader = new InputStreamReader(process.getInputStream());
|
||||||
if (line == null) {
|
bufferReader = new BufferedReader(inputStreamReader);
|
||||||
break;
|
while ((line = bufferReader.readLine()) != null) {
|
||||||
} else {
|
|
||||||
if (wdaConfig.isPrintWdaOutput()) {
|
if (wdaConfig.isPrintWdaOutput()) {
|
||||||
logger.debug("WDA-" + appleDevice.getConnectionDetail().serialNumber + "->" + line);
|
logger.debug("WDA-" + appleDevice.getConnectionDetail().serialNumber + "->" + line);
|
||||||
}
|
}
|
||||||
|
@ -133,16 +134,27 @@ public class MacIosDeviceInitThread extends IosDeviceInitThread {
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.warn("读取WDA输出时发生IO异常,设备" + appleDevice.getConnectionDetail().serialNumber, e);
|
logger.warn("读取WDA输出时发生IO异常,设备" + appleDevice.getConnectionDetail().serialNumber, e);
|
||||||
break;
|
}finally {
|
||||||
|
if (null != inputStreamReader) {
|
||||||
|
try {
|
||||||
|
inputStreamReader.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (null != bufferReader) {
|
||||||
|
try {
|
||||||
|
bufferReader.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} while (!isInterrupted());
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
exitCode = process.waitFor();
|
exitCode = process.waitFor();
|
||||||
} catch (InterruptedException ignored) {
|
} catch (InterruptedException ignored) {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (logOutput != null) {
|
if (logOutput != null) {
|
||||||
try {
|
try {
|
||||||
logOutput.close();
|
logOutput.close();
|
||||||
|
@ -150,6 +162,10 @@ public class MacIosDeviceInitThread extends IosDeviceInitThread {
|
||||||
logger.warn("关闭WDA独立日志流时发生IO异常,路径:{}", logFileName, e);
|
logger.warn("关闭WDA独立日志流时发生IO异常,路径:{}", logFileName, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
logger.debug("设备【{}】的wda退出了,重启一次......................", appleDevice.getConnectionDetail().serialNumber);
|
||||||
|
isFBServerReady = false;
|
||||||
|
}
|
||||||
|
logger.debug("设备【{}】的wda退出了,不在重启了......................", appleDevice.getConnectionDetail().serialNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -93,6 +93,7 @@ public class MobileSessionManager {
|
||||||
session.setMaxBinaryMessageBufferSize(50 * 1024 * 1024);
|
session.setMaxBinaryMessageBufferSize(50 * 1024 * 1024);
|
||||||
String deviceId = SpringUtils.getBean(MobileConnectService.class).getDeviceIdByToken(deviceToken);
|
String deviceId = SpringUtils.getBean(MobileConnectService.class).getDeviceIdByToken(deviceToken);
|
||||||
if (StringUtils.isBlank(deviceId)) {
|
if (StringUtils.isBlank(deviceId)) {
|
||||||
|
logger.debug("未获取到设备id对应的设备token:{}", deviceToken);
|
||||||
UpperWSResponse response = buildErrorMessage(null, "根据设备token获取设备id为空");
|
UpperWSResponse response = buildErrorMessage(null, "根据设备token获取设备id为空");
|
||||||
sendErrorMessageToWeb(session,JSON.toJSONString(response));
|
sendErrorMessageToWeb(session,JSON.toJSONString(response));
|
||||||
// closeSession(session, CloseReason.CloseCodes.CANNOT_ACCEPT,"根据设备token获取设备id为空!");
|
// closeSession(session, CloseReason.CloseCodes.CANNOT_ACCEPT,"根据设备token获取设备id为空!");
|
||||||
|
|
Loading…
Reference in New Issue