|
|
|
@ -32,6 +32,7 @@ import com.fr.workspace.WorkContext;
|
|
|
|
|
import com.fr.workspace.Workspace; |
|
|
|
|
import com.fr.workspace.base.WorkspaceConstants; |
|
|
|
|
import com.fr.workspace.connect.WorkspaceConnectionInfo; |
|
|
|
|
import com.fr.workspace.engine.exception.WorkspaceConnectionException; |
|
|
|
|
import com.fr.workspace.server.socket.CustomLogEvent; |
|
|
|
|
import com.fr.workspace.server.socket.LogEventConverter; |
|
|
|
|
import io.socket.client.IO; |
|
|
|
@ -207,6 +208,7 @@ public class DesignerSocketIO {
|
|
|
|
|
if (checkRPCConnect()) { |
|
|
|
|
showSocketDisconnectToast(); |
|
|
|
|
} else { |
|
|
|
|
FineLoggerFactory.getLogger().info("检查不通过"); |
|
|
|
|
showRPCDisconnectDialog(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -271,6 +273,11 @@ public class DesignerSocketIO {
|
|
|
|
|
httpGet.setConfig(requestConfig); |
|
|
|
|
try { |
|
|
|
|
CloseableHttpResponse response = httpclient.execute(httpGet); |
|
|
|
|
if (isErrorStatus(response.getStatusLine().getStatusCode())) { |
|
|
|
|
//这边nginx做负载,服务器被kill掉,返回的是502,不会抛错,导致checkRPCConnect通过
|
|
|
|
|
//针对500-600的错误码加个判断,其他类型的状态码暂不考虑,如果有遇到再处理,不然怕影响范围大
|
|
|
|
|
throw new WorkspaceConnectionException("Response " + response.getStatusLine().toString()); |
|
|
|
|
} |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
FineLoggerFactory.getLogger().error(e, e.getMessage()); |
|
|
|
|
return false; |
|
|
|
@ -278,6 +285,23 @@ public class DesignerSocketIO {
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 错误状态码 |
|
|
|
|
* 5xx(服务器错误)这些状态代码表示服务器在尝试处理请求时发生内部错误。 这些错误可能是服务器本身的错误,而不是请求出错。代码 说明 |
|
|
|
|
* 500 (服务器内部错误) 服务器遇到错误,无法完成请求。 |
|
|
|
|
* 501 (尚未实施) 服务器不具备完成请求的功能。 例如,服务器无法识别请求方法时可能会返回此代码。 |
|
|
|
|
* 502 (错误网关) 服务器作为网关或代理,从上游服务器收到无效响应。 |
|
|
|
|
* 503 (服务不可用) 服务器目前无法使用(由于超载或停机维护)。 通常,这只是暂时状态。 |
|
|
|
|
* 504 (网关超时) 服务器作为网关或代理,但是没有及时从上游服务器收到请求。 |
|
|
|
|
* 505 (HTTP 版本不受支持) 服务器不支持请求中所用的 HTTP 协议版本。 |
|
|
|
|
* |
|
|
|
|
* @param status 错误状态码 |
|
|
|
|
* @return 是否是错误状态码 |
|
|
|
|
*/ |
|
|
|
|
private static boolean isErrorStatus(int status) { |
|
|
|
|
return status >= 500 && status <= 600; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//配置变更监听器
|
|
|
|
|
private static final Emitter.Listener modifyConfig = new Emitter.Listener() { |
|
|
|
|
@Override |
|
|
|
|