Sentinel If have multiple network adapters. Multiple clients need to manually set different spring.cloud.sentinel.transport.client-ip

zhte4eai  于 2021-11-29  发布在  Java
关注(0)|答案(11)|浏览(276)

Issue Description

If have multiple network adapters. com.alibaba.csp.sentinel.util.HostNameUtil#resolveHost() May get an incorrect IP.
It will cause the sentinel-dashboard server to fail to connect to the client.

Describe what happened

Multiple clients need to manually set different spring.cloud.sentinel.transport.client-ip. A bit difficult

Describe what you expected to happen

Is it possible to get spring.cloud.sentinel.transport.client-ip through the sentry-dashboard server.

问题描述

如果有多个网络适配器. com.alibaba.csp.sentinel.util.HostNameUtil#resolveHost() 可能会获得一个不正确的 IP, 会导致 sentinel-dashboard 服务端不能连接到客户端.

发生了

多个客户端都要手动设置不同的 spring.cloud.sentinel.transport.client-ip, 有一点难受.

期望发生的事情

是否能够通过 sentinel-dashboard 服务端, 获得 spring.cloud.sentinel.transport.client-ip.

gkn4icbw

gkn4icbw2#

Maybe it's a new idea by adding TransportConfig.FETCH_FROM_SERVER and then dashboard get client's IP from HttpRequest, and we may think if it's indeed needed, and how about adding this as a configuration instead of removing HostNameUtil.getIp() ?

c6ubokkw

c6ubokkw4#

@sczyh30
Coming to this point i don't quite know the original purpose specifying the client ip programmatically instead of fetching the address of remote peer on dashboard automatically. (Surely if an address is brought in heartbeat request it can have a higher priority). Is there anything would make things mess?

tp5buhyn

tp5buhyn5#

I think it's reasonable why the client ip is carried in heartbeat message, since the pair(ip and port) can mark a unique machine of one application.Though ip can be got by dashboard automatically, it seems that port can't. One thing needed to be pay attention to is that the port is used by sentinel transport http server, and is not http port or dubbo port of application.

How do you see it and any suggestion? @sczyh30

4sup72z8

4sup72z86#

I agree with you and it's quite straightforward introducing a new property named port. And we certainly can make it backward compatible.

utugiqy6

utugiqy67#

Now the heartbeat message did has the port property.

  1. Fetching the address of remote peer on dashboard automatically.
  2. Add a config parameter csp.sentinel.heartbeat.client.ip.fetch.from.server, if set, fetch the ip by dashboard, else same as now.

Which is better? @jasonjoo2010@Deycoesr@sczyh30

3gtaxfhh

3gtaxfhh8#

Personally if no other bad effect i prefer fetch address on dashboard side if no address specified manually on client side. Thus, no new configuration item and better performance.

kuuvgm7e

kuuvgm7e9#

I'm a bit in favor of this method, but feel worried that it seems the previous way to obtain IP has to be removed. Is it useless to obtain client IP and put it into heartbeat message?

Besides, I found Dubbo also has issue about choosing ip when multiple network adapters, maybe we can learn from it.
Here is a discussion:
apache/dubbo#1557

One answer in the issue which I think is quite reasonable:

kx1ctssn

kx1ctssn10#

Dubbo has this issue and recommends users specifying it because registry doesn't have the ability to achieve such kind of logic.

And if something may go wrong changing the default behavior i certainly have no further question on introducing a new configuration.

46qrfjad

46qrfjad11#

this needs to consider the csp.sentinel.heartbeat.client.ip of lower version client will not work for higher version dashboard.

i think this will be better.

相关问题