incubator-seata
incubator-seata copied to clipboard
Unreal local address obtained by io.seata.common.util.NetUtil#getLocalIp
Ⅰ. Issue Description
When the project started, the 192.168.64.1 obtained is not my real ip.
Ⅱ. Describe what happened
2024-01-10 12:11:41.145 INFO [26943, ] --- [main] i.s.core.rpc.netty.NettyPoolableFactory : NettyPool create channel to transactionRole:TMROLE,address:193.168.11.122:8092,msg:< RegisterTMRequest{version='2.0.0', applicationId='stock-service', transactionServiceGroup='default-tx-group', extraData='ak=null
digest=default-tx-group,192.168.64.1,1704859901143
timestamp=1704859901143
authVersion=V4
vgroup=default-tx-group
ip=192.168.64.1
'} >
2024-01-10 12:11:41.152 ERROR [26943, ] --- [NettyClientSelector_TMROLE_1_1] i.s.c.r.n.AbstractNettyRemotingClient : 0318
java.io.IOException: Connection reset by peer
at sun.nio.ch.FileDispatcherImpl.read0(Native Method) ~[na:1.8.0_381]
at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:39) ~[na:1.8.0_381]
at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223) ~[na:1.8.0_381]
at sun.nio.ch.IOUtil.read(IOUtil.java:192) ~[na:1.8.0_381]
at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:378) ~[na:1.8.0_381]
at io.netty.buffer.PooledByteBuf.setBytes(PooledByteBuf.java:259) ~[netty-buffer-4.1.84.Final.jar:4.1.84.Final]
Ⅲ. Describe what you expected to happen
My local real ip is 193.168.11.122.
Ⅳ. How to reproduce it (as minimally and precisely as possible)
- xxx
- xxx
- xxx
Minimal yet complete reproducer code (or URL to code):
Ⅴ. Anything else we need to know?
Ⅵ. Environment:
- JDK version(e.g.
java -version
): 1.8 - Seata client/server version: 2.0.0
- Database version: mysql8
- OS(e.g.
uname -a
): macOS - Others:
是否存在多个网卡?如果存在多个网卡,请确保server的SEATA_IP配置无误或设置一下网卡偏好。 Is there more than one network card? If there are multiple NICs, make sure the server's SEATA_IP is configured correctly. Or set the network card preferences.
是否存在多个网卡?如果存在多个网卡,请确保server的SEATA_IP配置无误或设置一下网卡偏好。 Is there more than one network card? If there are multiple NICs, make sure the server's SEATA_IP is configured correctly. Or set the network card preferences.
是有多个网卡的,server 的SEATA_IP 配置是正确的,address:193.168.11.122:8092
,这个就是我本地 server 的地址, 如何设置网卡偏好?我直接使用 hutool 的工具包获取到的是我本地真实的 ip
See the preferred-networks
configuration item in this configuration file https://github.com/apache/incubator-seata/blob/2.x/server/src/main/resources/application.example.yml
@bydongxing Referring to the above method, has your issue been resolved?
我试了下还是不行,我看这边调用获取 本地 IP 的时候,并没有把 preferred-networks
配置的选项传递进来,不知道是不是我使用的问题?
please debug this line
String preferredNetworks = ConfigurationFactory.getInstance().getConfig(REGISTRY_PREFERED_NETWORKS);
if (StringUtils.isNotBlank(preferredNetworks)) {
XID.setIpAddress(NetUtil.getLocalIp(preferredNetworks.split(REGEX_SPLIT_CHAR)));
} else {
XID.setIpAddress(NetUtil.getLocalIp());
}
it seems need to
String REGISTRY_PREFERED_NETWORKS = ConfigurationKeys.FILE_ROOT_REGISTRY + ".preferredNetworks";
not preferred-networks
please debug this line
String preferredNetworks = ConfigurationFactory.getInstance().getConfig(REGISTRY_PREFERED_NETWORKS); if (StringUtils.isNotBlank(preferredNetworks)) { XID.setIpAddress(NetUtil.getLocalIp(preferredNetworks.split(REGEX_SPLIT_CHAR))); } else { XID.setIpAddress(NetUtil.getLocalIp()); }
it seems need to
String REGISTRY_PREFERED_NETWORKS = ConfigurationKeys.FILE_ROOT_REGISTRY + ".preferredNetworks";
not preferred-networks
我在这边打断点,好像并没有调用这个方法呢?
那看代码,没有别的地方会获取这个配置来传递到netutil方法的。
这个你看看走到你之前debug 为空入参的时候,这个调用栈是怎么样的
我试了下还是不行,我看这边调用获取 本地 IP 的时候,并没有把
preferred-networks
配置的选项传递进来,不知道是不是我使用的问题?
Is the ip you're talking about the CLIENT side or the SERVER side? 你说的ip到底是client侧还是server侧
我试了下还是不行,我看这边调用获取 本地 IP 的时候,并没有把
preferred-networks
配置的选项传递进来,不知道是不是我使用的问题?![]()
![]()
Is the ip you're talking about the CLIENT side or the SERVER side? 你说的ip到底是client侧还是server侧
client 侧的,就是我本地是多网卡的,然后启动 seata 的 client 的时候,获取到的 IP 有问题的
client侧并没有这个配置,怪不得没有生效,请问这个ip不对的情况下,对server二阶段的下发产生了影响吗? The client side doesn't have this configuration, so no wonder it didn't take effect, did this ip not being correct have an effect on the server second stage down?