Problems on registering service with catalog API

I registered a service with “curl --request PUT --data @payload.jsonhttp://’”. I can list the service with “/v1/catalog/service/consul_register_test10” for a short time.

However,after about 90 seconds,the service just disappeared. The list query responsed with null.

Please give me a hand and thanks.

P.S.The version is Consul v1.7.3 .

Hi @horace_he,

This is caused due to Consul’s anti-entropy sync - Anti-Entropy | Consul by HashiCorp.

During this synchronization, the catalog is also checked for correctness. If any services or checks exist in the catalog that the agent is not aware of, they will be automatically removed to make the catalog reflect the proper set of services and health information for that agent. Consul treats the state of the agent as authoritative; if there are any differences between the agent and catalog view, the agent-local view will always be used.

You should be registering the services via a local consul agent using the /v1/agent/service endpoint - Service - Agent - HTTP API | Consul by HashiCorp instead of the catalog API.

1 Like

Thany you very much. That helps a lot.

I’m using /v1/agent/service right now. I’m running a cluster with three servers. Between services and servers,there is a nginx cluster which uses round-robin transfer policy.Sometimes i comes failures on deregistering beacause the deregistering requirement does not go to the registered node.
So there is a requirement that i should deregister services on the node which the services isn’t registered on.I’m just wondering if catalog API could make a diffrence.

From your guidence,it seems that i should always use agent to register services. Is there any solutions for my problems?