开发者社区 > 云原生 > 正文

建立连接的端口不是配置文件中指定的端口

consumer配置指定dubbo端口是7001,provider配置指定的dubbo端口是5001,

但是建立连接时却是:The connection of /192.168.0.109:51490 -> /192.168.0.109:5001 is established,

导致调用接口时报No provider异常。 其中这个5位数的端口不是配置指定的,而且每次重启会改变。

Dubbo version: 2.7.8 Java version: 1.8 服务启动顺序:先启动consumer,再启动provider。 provider启动完成时consumer打出来的日志:

2023-03-02 00:35:55.615 INFO 20228 --- [ncesChangeEvent] a.DubboServiceDiscoveryAutoConfiguration : The event of the service instances[name : ds-service , size : 1] change is about to be dispatched 2023-03-02 00:35:55.616 WARN 20228 --- [ncesChangeEvent] c.a.c.dubbo.registry.DubboCloudRegistry : APP ds-service instance changed, size changed zero!!! 2023-03-02 00:35:58.802 INFO 20228 --- [ncesChangeEvent] a.DubboServiceDiscoveryAutoConfiguration : The event of the service instances[name : ds-service , size : 1] change is about to be dispatched 2023-03-02 00:35:58.802 INFO 20228 --- [ncesChangeEvent] c.a.c.dubbo.registry.DubboCloudRegistry : APP ds-service instance changed, size changed to 1 2023-03-02 00:35:58.802 WARN 20228 --- [ncesChangeEvent] c.a.c.dubbo.registry.DubboCloudRegistry : Subscription app ds-service, can't find metadata handler 2023-03-02 00:35:58.804 INFO 20228 --- [ncesChangeEvent] c.a.c.d.s.DubboMetadataServiceProxy : The metadata of Dubbo service[name : ds-service] is about to be initialized 2023-03-02 00:35:58.807 INFO 20228 --- [ncesChangeEvent] c.a.c.dubbo.registry.DubboCloudRegistry : [DUBBO] Register: consumer://192.168.187.1/org.apache.dubbo.rpc.service.GenericService?application=ds-web&category=consumers&check=false&dubbo=2.0.2&generic=true&group=ds-service&interface=com.alibaba.cloud.dubbo.service.DubboMetadataService&pid=20228&qos.enable=false&release=2.7.8&retries=0&router=-default,revisionRouter&side=consumer&sticky=false&timeout=10000&timestamp=1677688558806&version=1.0.0, dubbo version: 2.7.8, current host: 192.168.187.1 2023-03-02 00:35:58.808 INFO 20228 --- [ncesChangeEvent] c.a.c.dubbo.registry.DubboCloudRegistry : [DUBBO] Subscribe: consumer://192.168.187.1/org.apache.dubbo.rpc.service.GenericService?application=ds-web&category=providers,configurators,routers&check=false&dubbo=2.0.2&generic=true&group=ds-service&interface=com.alibaba.cloud.dubbo.service.DubboMetadataService&pid=20228&qos.enable=false&release=2.7.8&retries=0&router=-default,revisionRouter&side=consumer&sticky=false&timeout=10000&timestamp=1677688558806&version=1.0.0, dubbo version: 2.7.8, current host: 192.168.187.1 2023-03-02 00:35:58.843 INFO 20228 --- [lientWorker-4-1] o.a.d.r.t.netty4.NettyClientHandler : [DUBBO] The connection of /192.168.0.109:51490 -> /192.168.0.109:5001 is established., dubbo version: 2.7.8, current host: 192.168.187.1 2023-03-02 00:35:58.849 INFO 20228 --- [ncesChangeEvent] o.a.d.remoting.transport.AbstractClient : [DUBBO] Successed connect to server /192.168.0.109:5001 from NettyClient 192.168.187.1 using dubbo version 2.7.8, channel is NettyChannel [channel=[id: 0xa98087e1, L:/192.168.0.109:51490 - R:/192.168.0.109:5001]], dubbo version: 2.7.8, current host: 192.168.187.1 2023-03-02 00:35:58.849 INFO 20228 --- [ncesChangeEvent] o.a.d.remoting.transport.AbstractClient : [DUBBO] Start NettyClient /192.168.187.1 connect to the server /192.168.0.109:5001, dubbo version: 2.7.8, current host: 192.168.187.1 2023-03-02 00:35:58.855 INFO 20228 --- [ncesChangeEvent] org.apache.dubbo.config.ReferenceConfig : [DUBBO] Refer dubbo service org.apache.dubbo.rpc.service.GenericService from url spring-cloud://192.168.187.128:9090/org.apache.dubbo.registry.RegistryService?anyhost=true&application=ds-web&bind.ip=192.168.0.109&bind.port=5001&check=false&deprecated=false&dubbo=2.0.2&dynamic=true&generic=true&group=ds-service&interface=com.alibaba.cloud.dubbo.service.DubboMetadataService&methods=getAllServiceKeys,getServiceRestMetadata,getExportedURLs,getAllExportedURLs&payload=102400000&pid=20228&qos.enable=false&register.ip=192.168.187.1&release=2.7.8&remote.application=ds-service&retries=0&revision=2.2.6.RELEASE&router=-default,revisionRouter&sca_revision=0&side=consumer&sticky=false&timeout=10000&timestamp=1677688558806&version=1.0.0, dubbo version: 2.7.8, current host: 192.168.187.1

provider最后一行日志:

2023-03-02 00:35:58.858 INFO 15492 --- [erverWorker-3-1] o.a.d.r.t.netty4.NettyServerHandler : [DUBBO] The connection of /192.168.0.109:51490 -> /192.168.0.109:5001 is established., dubbo version: 2.7.8, current host: 192.168.187.1

consumer的配置:

dubbo: protocol: name: dubbo payload: 102400000 port: 7001 registry: address: spring-cloud://192.168.187.128 cloud: subscribed-services: ds-service consumer: check: false retries: 0 timeout: 10000 application: name: ds-web

provider的配置:

dubbo: scan: base-package: com.demo.dsservice protocol: name: dubbo payload: 102400000 port: 5001 registry: address: spring-cloud://192.168.187.128 cloud: subscribed-services: consumer: check: false timeout: 10000 application: name: ds-service

原提问者GitHub用户nemowang

展开
收起
大圣东游 2023-05-11 15:49:46 328 0
1 条回答
写回答
取消 提交回答
  • dubbo的端口配置是用于对外暴露服务,供consumer使用的,你consumer端配置的端口也只是用于给别人调用你的consumer提供的dubbo服务用的,作为consumer调用provider服务使用的端口是不能指定的,就好像你使用httpclient去调用一个80端口的服务,你是不能控制client使用哪个端口发送数据的

    原回答者GitHub用户MartinDai

    2023-05-12 10:21:03
    赞同 展开评论 打赏

阿里云拥有国内全面的云原生产品技术以及大规模的云原生应用实践,通过全面容器化、核心技术互联网化、应用 Serverless 化三大范式,助力制造业企业高效上云,实现系统稳定、应用敏捷智能。拥抱云原生,让创新无处不在。

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载