Skip to content

Commit

Permalink
try_fix_connection
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhouYixun committed Sep 3, 2022
1 parent 1ee4b65 commit 0b75854
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 9 deletions.
21 changes: 21 additions & 0 deletions .github/ISSUE_TEMPLATE/bug------bug-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
name: Bug 报告 | Bug report
about: Create a report to help us improve
title: "【Bug】"
labels: bug
assignees: ''

---

**在提出此issue时,我确认了以下几点(保存后请点击复选框):**

- [ ] 我已自己确认这是Sonic自身的Bug。
- [ ] 我接受此issue可能被关闭,并查看开发人员的建议。

**Bug 描述**
清晰地描述Bug的情况与详细复现步骤 | A clear and concise description of what the bug is.

**版本**
Sonic的版本号 | Sonic's Version.
部署的系统(mac,windows32...) | System

9 changes: 9 additions & 0 deletions .github/pull-request-template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
**在提出此拉取请求时,我确认了以下几点(保存后请点击复选框):**

- [ ] 我已检查没有与此请求重复的拉取请求。
- [ ] 我已经考虑过,并确认这份呈件对其他人很有价值。
- [ ] 我接受此提交可能不会被使用,并根据维护人员的意愿关闭拉取请求。

**填写PR内容:**

-
22 changes: 13 additions & 9 deletions cmd/run/wda.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/mitchellh/mapstructure"
"github.com/spf13/cobra"
"io"
"io/ioutil"
"log"
"net"
"net/http"
Expand Down Expand Up @@ -118,20 +119,24 @@ var wdaCmd = &cobra.Command{
go func() {
var resp *http.Response
var httpErr error
var checkTime = 0
ticker := time.NewTicker(time.Second * 10)
c := &http.Client{
Timeout: 2 * time.Second,
}
for {
select {
case <-ticker.C:
resp, httpErr = http.Get(fmt.Sprintf("http://127.0.0.1:%d/health", serverLocalPort))
resp, httpErr = c.Get(fmt.Sprintf("http://127.0.0.1:%d/health", serverLocalPort))
var re string
if httpErr != nil {
fmt.Printf("request fail: %s", httpErr)
continue
}
if resp.StatusCode == 200 {
fmt.Printf("wda server health checked %d times: ok\n", checkTime)
fmt.Println("WebDriverAgent server health timeout.")
} else {
stopTest()
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
re = string(body)
}
if httpErr != nil || re != "I-AM-ALIVE" {
fmt.Println("WebDriverAgent server unhealthy.")
var upTimes = 0
for {
output, stopTest, err2 = device.XCTest(wdaBundleID, giDevice.WithXCTestEnv(testEnv))
Expand Down Expand Up @@ -189,7 +194,6 @@ func proxy() func(listener net.Listener, port int, device giDevice.Device) {
if accept, err = listener.Accept(); err != nil {
log.Println("accept:", err)
}
fmt.Println("accept", accept.RemoteAddr())
rInnerConn, err := device.NewConnect(port)
if err != nil {
fmt.Println("connect to device fail")
Expand Down

0 comments on commit 0b75854

Please sign in to comment.