sofastack / sofa-rpc

SOFARPC is a high-performance, high-extensibility, production-level Java RPC framework.
https://www.sofastack.tech/sofa-rpc/docs/Home
Apache License 2.0
3.81k stars 1.17k forks source link

Failed to register the service to Nacos registry when wrongly setting "com.alipay.sofa.rpc.bind-network-interface" #1297

Closed tcfly closed 1 year ago

tcfly commented 1 year ago

Describe the bug

com.alipay.sofa.rpc.core.exception.SofaRpcRuntimeException: RPC-010060007: Failed to register provider to [NacosRegistry]! service:[demo.DemoService:] 
        at com.alipay.sofa.rpc.registry.nacos.NacosRegistry.register(NacosRegistry.java:193)
        at com.alipay.sofa.rpc.boot.container.ProviderConfigContainer.publishAllProviderConfig(ProviderConfigContainer.java:122)
        at com.alipay.sofa.rpc.boot.context.SofaBootRpcStartListener.onApplicationEvent(SofaBootRpcStartListener.java:83)
        at com.alipay.sofa.rpc.boot.context.SofaBootRpcStartListener.onApplicationEvent(SofaBootRpcStartListener.java:41)
        at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
        at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
        at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
        at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:402)
        at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:359)
        at com.alipay.sofa.rpc.boot.context.ApplicationContextRefreshedListener.onApplicationEvent(ApplicationContextRefreshedListener.java:38)
        at com.alipay.sofa.rpc.boot.context.ApplicationContextRefreshedListener.onApplicationEvent(ApplicationContextRefreshedListener.java:31)
        at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
        at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
        at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
        at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:402)
        at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:359)
        at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:896)
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.java:162)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:552)
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141)
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:744)
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:391)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:312)
        at demo.SpringApplicationDemo.main(SpringApplicationDemo.java:28)
Caused by: java.lang.IllegalStateException: failed to req API:/nacos/v1/ns/instance after all servers([127.0.0.1:8848]) tried: failed to req API:http://127.0.0.1:8848/nacos/v1/ns/instance. code:400 msg: caused: Param 'ip' is required.;
        at com.alibaba.nacos.client.naming.net.NamingProxy.reqAPI(NamingProxy.java:380)
        at com.alibaba.nacos.client.naming.net.NamingProxy.reqAPI(NamingProxy.java:304)
        at com.alibaba.nacos.client.naming.net.NamingProxy.registerService(NamingProxy.java:186)
        at com.alibaba.nacos.client.naming.NacosNamingService.registerInstance(NacosNamingService.java:298)
        at com.alibaba.nacos.client.naming.NacosNamingService.registerInstance(NacosNamingService.java:279)
        at com.alipay.sofa.rpc.registry.nacos.NacosRegistry.register(NacosRegistry.java:182)
        ... 23 common frames omitted

Expected behavior

When wrongly setting "com.alipay.sofa.rpc.bind-network-interface" to a network interface that does not exist on the machine, and it does happen , the Instance deserves a default ip instead of an empty string "".

Actual behavior

Steps to reproduce

Minimal yet complete reproducer code (or GitHub URL to code)

Environment

EvenLjj commented 1 year ago

@tcfly Thank you for your feedback. We will review it as soon as possible.

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.