Skip to content

Commit

Permalink
optimize :
Browse files Browse the repository at this point in the history
调整请求超时时间为2分钟;
默认请求10s超时,当maxsize设置最大值10000行时可能会导致请求时间过长,从而超出10s时间,导致无法获取数据
  • Loading branch information
flashine committed Jul 8, 2022
1 parent f7208aa commit dea56f7
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ private void addScrollBarListener(TableView<?> view){
@Override
protected Void call() {
HashMap<String, String> result = helper.getHTML(client.getParam(String.valueOf(bean.page),
isAll.isSelected()) + helper.encode(text), 10000, 10000);
isAll.isSelected()) + helper.encode(text), 120000, 120000);
TableView<TableBean> tableView = (TableView<TableBean>) ((BorderPane) tab.getContent()).getCenter();
if (result.get("code").equals("200")) {
JSONObject obj = JSON.parseObject(result.get("msg"));
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/fofaviewer/main/MainApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.fofaviewer.controllers.MainController;

public class MainApp extends Application {
private final String version = "1.1.9";
private final String version = "1.1.10";

@Override
public void start(Stage stage) throws Exception {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/fofaviewer/request/Request.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void query(int connection){
bean.setRequestStatus(RequestStatus.RUNNING);
TabDataBean _tmp = new TabDataBean();
Platform.runLater(() -> this.callback.before(_tmp, bean));
HashMap<String, String> res = RequestUtil.getInstance().getHTML(bean.getRequestUrl(), 10000, 10000);
HashMap<String, String> res = RequestUtil.getInstance().getHTML(bean.getRequestUrl(), 120000, 120000);
bean.setResult(res);
if (res.get("code").equals("error") || !res.get("code").equals("200")) {
bean.setRequestStatus(RequestStatus.FAILED);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/fofaviewer/utils/RequestUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public HashMap<String, String> getHTML(String url, int connectTimeout, int socks
.socksTimeout(socksTimeout)
.send();
}catch (Exception e){
Logger.warn(e);
Logger.warn(url + e.getMessage());
result.put("code", "error");
result.put("msg", e.getMessage());
return result;
Expand Down Expand Up @@ -155,7 +155,7 @@ public HashMap<String, String> getImageFavicon(String url) {
}

public String getLinkIcon(String url) {
HashMap<String, String> result = getHTML(url, 10000,10000);
HashMap<String, String> result = getHTML(url, 60000,60000);
if (result.get("code").equals("200")) {
Document document = Jsoup.parse(result.get("msg"));
Elements elements = document.getElementsByTag("link");
Expand Down Expand Up @@ -250,7 +250,7 @@ public Map<String,String> getTips(String key) {
String ts = String.valueOf((new Timestamp(System.currentTimeMillis())).getTime());
String singParam = "q" + key + "ts" + ts;
String params = URLEncoder.encode(key,"UTF-8") + "&ts=" + ts + "&sign=" + URLEncoder.encode(getInputSign(singParam), "utf-8") + "&app_id=" + this.appId;
HashMap<String, String> result = getHTML(FofaConfig.TIP_API + params, 3000, 5000);
HashMap<String, String> result = getHTML(FofaConfig.TIP_API + params, 5000, 10000);
if (result.get("code").equals("200")) {
JSONObject obj = JSON.parseObject(result.get("msg"));
if(obj.getInteger("code") == 0){
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/tinylog.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
writer1=rolling file
writer1.level=error
writer1.level=error,warn
writer1.format={date:yyyy-MM-dd HH:mm:ss.SSS} {level} {file}.java:{line}-{method}:\n{message}
writer1.file=log/error_{date:yyyy-MM-dd}.log
writer1.append=true
Expand All @@ -8,4 +8,5 @@ writer1.writingthread=true
writer1.policies = startup
writer2=console
writer2.level=warn
writer2.append=true
writer2.format={date:yyyy-MM-dd HH:mm:ss.SSS} {level} {file}.java:{line}-{method}:\n{message}

0 comments on commit dea56f7

Please sign in to comment.