2

I use Go-micro(v2) to deploy services inside docker-compose

  user-service:
    build:
      context: ./user-service
    restart: always
    ports:
      - "8086:8086"
    deploy:
      mode: replicated
      replicas: 1
    environment:....

See the service configuration

srv = micro.NewService(
            micro.Name("my.user"),
            micro.Address("127.0.0.1:8086"))

when running docker-compose, the container logs show

2022-07-31 05:43:53  file=v2@v2.9.1/service.go:200 level=info Starting [service] my.user
2022-07-31 05:43:53  file=grpc/grpc.go:864 level=info Server [grpc] Listening on [::]:8086
2022-07-31 05:43:53  file=grpc/grpc.go:697 level=info Registry [mdns] Registering node: my.user-00ee4795-06df-47f1-a07a-cc362e135864

All looks good.

But when I want to query some handlers using curl or postman(for development purpose), It doesn't work,

see an exemple of failed request with postman

GET http://127.0.0.1:8086/my.user/Get
Error: Parse Error: Expected HTTP/
Request Headers
Content-Type: application/json
User-Agent: PostmanRuntime/7.29.2
Accept: */*
Postman-Token: b5ab718a-341b-40ff-81fa-37c66fd4d9f2
Host: 127.0.0.1:8086
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Request Body


GET http://127.0.0.1:8086/my.user/userService/Get // same error

with curl it is not better

curl --header "Content-Type:application/json" --http0.9 --output GET http://localhost:8086/my.user/Get
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    15    0    15    0     0  10638      0 --:--:-- --:--:-- --:--:-- 15000

curl --header "Content-Type:application/json" --http0.9 --output GET http://localhost:8086/my.user/userService/Get
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    15    0    15    0     0  13550      0 --:--:-- --:--:-- --:--:-- 15000

Any idea how to query locally some go-micro services ? Thank you.

ps: Note that the 'Get' handler is working

Jerome
  • 294
  • 2
  • 14
  • Your curl output looks like a success to me . As for the postman, GET shouldn't include a host, just a path. I'm not sure how you managed to get postma. – erik258 Aug 01 '22 at 01:51
  • yes it connect with the container but it does not reach the handler of the service, `http://localhost:8086/my.user/userService/Get`, `http://localhost:8086/my.user/Get`, `http://localhost:8086/Get`, give the same response which is nothing...(instead it should return an error). I found out in some docs that building a go-micro's client to link the rest request to the handlers would make it. But by default it should work out of the box, unfortunatly it doesn't, I should miss something somewhere. – Jerome Aug 01 '22 at 12:08

0 Answers0