dial tcp 127.0.0.1:8088: Connection refused #512
-
I use resty in wasm application, and got "dial tcp 127.0.0.1:8088: Connection refused". http.Get() got the correct response. func tryResty() {
fmt.Println("try http get=========================OK")
r, err := http.Get("/v2/demo/ping")
if err != nil {
app.Log(err)
return
}
defer r.Body.Close()
b, err := ioutil.ReadAll(r.Body)
if err != nil {
app.Log(err)
return
}
fmt.Println(string(b))
fmt.Println("try resty get=========================Failed")
resp, err := resty.New().R().Get("http://127.0.0.1:8088/v2/demo/ping")
if err != nil {
fmt.Println(err.Error())
return
}
fmt.Println(string(resp.Body()))
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
I can't replicate your claims:
What version of Go? Resty? Are you doing other things with the I'm testing with Go v1.17.5, resty v2.7.0, and the following: package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
"github.com/go-resty/resty/v2"
)
func main() {
fmt.Println("try http get=========================")
r, err := http.Get("/v2/demo/ping")
if err != nil {
log.Fatal(err)
}
defer r.Body.Close()
b, err := ioutil.ReadAll(r.Body)
if err != nil {
log.Fatal(err)
}
fmt.Println(string(b))
fmt.Println("try resty get=========================")
resp, err := resty.New().R().Get("http://127.0.0.1:8088/v2/demo/ping")
if err != nil {
fmt.Println(err.Error())
return
}
fmt.Println(string(resp.Body()))
} |
Beta Was this translation helpful? Give feedback.
-
It will be ok if run the test func in a normal windows or linux application, but wrong as a wasm app. ...
resp, err := resty.New().
SetTransport(http.DefaultTransport).
R().
Get("http://127.0.0.1:8088/v2/demo/ping")
... |
Beta Was this translation helpful? Give feedback.
I can't replicate your claims:
What version of Go? Resty? Are you doing other things with the
http
package outside of this function? Can you provide a standalone reproducer (a simplemain.go
)?I'm testing with Go v1.17.5, resty v2.7.0, and the following: