@@ -16,7 +16,7 @@ import (
1616 "time"
1717)
1818
19- var currentSessionID , host , hubUrl string
19+ var currentSessionID , host , hubUrl , id string
2020var maxDuration , port int
2121
2222func main () {
@@ -38,6 +38,7 @@ func main() {
3838 log .Infof ("port: %v" , port )
3939 log .Infof ("maxDuration: %v" , maxDuration )
4040
41+ id = "http://" + host + ":" + strconv .Itoa (port )
4142 register ()
4243
4344 go func () {
@@ -82,8 +83,11 @@ func getIpv4() (string, error) {
8283func register () {
8384 log .Info ("Try register" )
8485 register := jsonwire.Register {
85- Configuration : & jsonwire.Configuration {Host : host , Port : port },
86- CapabilitiesList : []jsonwire.Capabilities {{"browserName" : "firefox" }},
86+ Configuration : & jsonwire.Configuration {
87+ Id : id ,
88+ Host : host ,
89+ Port : port ,
90+ CapabilitiesList : []jsonwire.Capabilities {{"browserName" : "firefox" }}},
8791 }
8892 b , err := json .Marshal (register )
8993 if err != nil {
@@ -130,8 +134,8 @@ func register() {
130134
131135// sendApiProxy check "is server know me" and register if server return false
132136func sendApiProxy () error {
133- b := strings .NewReader ("{}" )
134- req , err := http .NewRequest (http .MethodPost , hubUrl + "/grid/api/proxy?id=http://" + host + ":" + strconv . Itoa ( port ) , b )
137+ b := strings .NewReader (`{id:"` + id + `"}` )
138+ req , err := http .NewRequest (http .MethodPost , hubUrl + "/grid/api/proxy?id=" + id , b )
135139 if err != nil {
136140 return fmt .Errorf ("create request error, %s" , err )
137141 }
@@ -163,6 +167,7 @@ func sendApiProxy() error {
163167 }
164168 if ! respStruct .Success {
165169 log .Info ("Node not registered on hub" )
170+ log .Info (string (respBytes ))
166171 register ()
167172 }
168173 return nil
0 commit comments