zeromicro / go-zero

A cloud-native Go microservices framework with cli tool for productivity.
https://go-zero.dev
MIT License
29.09k stars 3.93k forks source link

Problem on API server connects RPC server. #4278

Open freeFesei opened 2 months ago

freeFesei commented 2 months ago

rpc 端已经连接到了 etcd 中 etcd 的版本是 3.5.4

image

但是 api 去连接的时候报错

image

2024/07/27 20:27:18 rpc dial: etcd://localhost:2379/user.rpc, error: context deadline exceeded, make sure rpc service “user.rpc” is already started

colinrs commented 2 months ago

你的服务监听的是 192.168.10.3, 如果你在同一台机器上尝试通过 localhost 或 127.0.0.1 连接这个服务,默认情况下是不行的。 原因: localhost 和 127.0.0.1 是指向回环接口的特殊地址。 当服务绑定到特定 IP 地址时,它只监听那个特定的网络接口。 回环接口和实际的网络接口是分开的。 解决方法: 如果你希望服务既能通过具体 IP 访问,又能通过 localhost 访问,你可以:修改服务配置,使其监听 0.0.0.0:8080 这将使服务监听所有可用的网络接口,包括回环接口。

Issues-translate-bot commented 2 months ago

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Your service is listening on 192.168.10.3. If you try to connect to this service through localhost or 127.0.0.1 on the same machine, it will not work by default. reason: localhost and 127.0.0.1 are special addresses that point to the loopback interface. When a service is bound to a specific IP address, it only listens on that specific network interface. The loopback interface is separate from the actual network interface. Solution: If you want the service to be accessible both through a specific IP and through localhost, you can: Modify the service configuration so that it listens on 0.0.0.0:8080 This will cause the service to listen on all available network interfaces, including the loopback interface.

lartikzhong-lb commented 1 month ago

你的服务监听的是 192.168.10.3, 如果你在同一台机器上尝试通过 localhost 或 127.0.0.1 连接这个服务,默认情况下是不行的。 原因: localhost 和 127.0.0.1 是指向回环接口的特殊地址。 当服务绑定到特定 IP 地址时,它只监听那个特定的网络接口。 回环接口和实际的网络接口是分开的。 解决方法: 如果你希望服务既能通过具体 IP 访问,又能通过 localhost 访问,你可以:修改服务配置,使其监听 0.0.0.0:8080 这将使服务监听所有可用的网络接口,包括回环接口。

为什么感觉怪怪的,etcd作为服务注册,对于服务192.168.10.3:8080 返回客户端去连接,客户端 不就可以去连接了吗?

Issues-translate-bot commented 1 month ago

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Your service is listening on 192.168.10.3. If you try to connect to this service through localhost or 127.0.0.1 on the same machine, it will not work by default. Reason: localhost and 127.0.0.1 are special addresses pointing to the loopback interface. When a service is bound to a specific IP address, it only listens on that specific network interface. The loopback interface is separate from the actual network interface. Workaround: If you want the service to be accessible via both a specific IP and localhost, you can: Modify the service configuration so that it listens on 0.0.0.0:8080 This will cause the service to listen on all available network interfaces, including the loopback interface.

Why does it feel weird? etcd is registered as a service. For the service 192.168.10.3:8080, it returns to the client to connect. Can the client connect?