apache / apache/dubbo-js

注册 nacos 服务时的端口未指定,导致无法建立长连接

Open
#250 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
776
Forks
157
PR merge metrics
No merged PRs in 30d

Description

在 dubbo.ts 的第 [133 行](https://github.com/apache/dubbo-js/blob/master/packages/dubbo-consumer/src/dubbo.ts#L133)

```javascript
this.consumers.push({
dubboServiceInterface: dubboInterface,
dubboServiceUrl: `consumer://${ip.address()}/${dubboInterface}?${qs.stringify(
{
application: this.props.application.name,
interface: dubboInterface,
category: 'consumers',
method: '',
revision: version,
version: group,
group: version,
timeout: timeout,
side: 'consumer',
check: false,
pid: process.pid
}
)}`
```

通过 ip.address() 只能获取到当前的 ip,并不能获取到当前程序运行的端口。

然后往 nacos 注册该 consumer 服务的时候([registy-nacos.ts L149-L153](https://github.com/apache/dubbo-js/blob/master/packages/dubbo-registry/src/registry-nacos.ts#L149-L153)),就会使用默认的 80 端口,并导致无法建立连接。

```javascript
// registry-nacos.ts L149-L153
await this.client.registerInstance(dubboServiceInterface, {
ip,
port: port || 80,
metadata
})
```

我找了一圈,似乎并没有可以获取到当前运行端口的方法。或许要在 registry 的时候,配置一下端口?

另外,因为我的电脑配置了两个 IP 地址,实际上 ip.address() 只能获取到第一个([ip 源码](https://github.com/indutny/node-ip/blob/master/lib/ip.js#L396)),虽然我这不是常见情况,但是可否支持一下配置,如果没有配置的话,则 fallback 到 ip.address()?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.