sofastack / sofa-rpc-node Goto Github PK
View Code? Open in Web Editor NEWSOFARPC Node is a high-performance, high-extensibility, production-level Nodejs RPC framework.
License: MIT License
SOFARPC Node is a high-performance, high-extensibility, production-level Nodejs RPC framework.
License: MIT License
请问是否可以支持路由匹配的基础能力,比如根据请求中的某些tag,可以先从地址列表中筛选出某些符合条件的地址,然后再loadbalance
类似dubbo sdk提供的标签路由功能:https://cn.dubbo.apache.org/zh-cn/docs/advanced/routing-rule/#%E6%A0%87%E7%AD%BE%E8%B7%AF%E7%94%B1%E8%A7%84%E5%88%99
2018-11-25 11:23:47,345 WARN 8708 nodejs.ResponseTimeoutError: register to channel: [email protected]:2181 failed, will retry after 3s, Server no response in 3000ms, address#127.0.0.1:7777
直连模式可以调用,但是使用 ZookeeperRegistry 就一直报上面的错
Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
Describe the solution you'd like
A clear and concise description of what you want to happen.
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.
只需要远程调用, 不需要返回任何结果, 每次都告诉我'RpcResponseTimeoutError'
Describe the bug
Trying to connect to JAVA server using SOFA boot, the service was connected but when I invoke the method, got error
RPC-02412: Cannot find invoke method
I have tried every combination of the method on the server, but doesn't work. Any Idea what to put in the method?
Thanks!
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Expected response in server logs or even other errors
After the connection expired , it will auto reconnect , but how can we re-publish the provider ?
is there any way to do sth like this :
server.start()
.then(async () => {
server.publish();
server.on('server:event', async (e) => {
if (e.type === 'zookeeper' && e.name === 'connected') {
server.services.get(e.id).rePublish();
}
});
});
1、按照demo创建两个进程,一个RpcServer使用12200端口,另一个使用12201端口
'use strict';
const { RpcServer } = require('sofa-rpc-node').server;
const { ZookeeperRegistry } = require('sofa-rpc-node').registry;
const logger = console;
// 1. 创建 zk 注册中心客户端
const registry = new ZookeeperRegistry({
logger,
address: '127.0.0.1:2181', // 需要本地启动一个 zkServer
});
// 2. 创建 RPC Server 实例
const server = new RpcServer({
logger,
registry, // 传入注册中心客户端
port: 12200, // 另一个使用12201
});
// 3. 添加服务
server.addService({
interfaceName: 'com.nodejs.test.TestService',
}, {
async plus(a, b) {
console.log(arguments)
return a + b;
},
});
// 4. 启动 Server 并发布服务
server.start()
.then(() => {
server.publish();
});
2、ZK显示/sofa-rpc/com.nodejs.test.TestService/providers
有两个节点
[bolt%3A%2F%2F10.39.190.174%3A12200%3FstartTime%3D1550489950969%26pid%3D41913%26uniqueId%3D%26dynamic%3Dtrue%26appName%3D%26timeout%3D3000%26serialization%3Dhessian2%26weight%3D100%26accepts%3D100000%26language%3Dnodejs%26rpcVer%3D50400%26protocol%3D%26interface%3Dcom.nodejs.test.TestService%26version%3D1.0%26group%3DSOFA, bolt%3A%2F%2F10.39.190.174%3A12201%3FstartTime%3D1550489964826%26pid%3D41915%26uniqueId%3D%26dynamic%3Dtrue%26appName%3D%26timeout%3D3000%26serialization%3Dhessian2%26weight%3D100%26accepts%3D100000%26language%3Dnodejs%26rpcVer%3D50400%26protocol%3D%26interface%3Dcom.nodejs.test.TestService%26version%3D1.0%26group%3DSOFA]
2、关闭其中一个进程
3、过一段时间后,ZK显示/sofa-rpc/com.nodejs.test.TestService/providers
下为空
[]
期望另一个进程应该继续提供服务才对
java 版本 sofarpc 可以通过 RpcInvokeContext 把数据给透传。想问node 版本是否支持?
在 invoke
时,如果目标服务器出现网络不可达,或是短暂的繁忙造成请求响应超时时,有没有需要加入重试机制
执行npm i
后会删除 .travis.yml
的before_install
指令
-before_install:
- - 'wget https://archive.apache.org/dist/zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz'
- - 'tar xf zookeeper-3.4.6.tar.gz'
- - 'mv zookeeper-3.4.6/conf/zoo_sample.cfg zookeeper-3.4.6/conf/zoo.cfg'
- - './zookeeper-3.4.6/bin/zkServer.sh start'
data_client文件中 zk 重连函数,for循环,遍历 map的keys,并且会触发 zookeeper-client:watcher事件
api_client中监听zookeeper-client:watcher 最终会触发data_client的invokeWithWatcher,因为是操作的同一个map _watchers 会导致一个死循环,map永远无法清空,所以需将data_client中的 for (const key of this._watchers.keys()) 替换为
const keys = [...this._watchers.keys()];
for(const key of keys)
ts写的node服务根本无法调用,是否官方可以支持?
如何在服务器和客户端同时注册多个Zookeeper 地址 (Zookeeper Cluster)
需求:希望有 addressList 固定顺序,或者是有个类似优先级的匹配逻辑、
哈喽,想问下,client 这里的 addressList 为什么要sort排序,默认的roundRobin看着好像也有排序。那现在还有办法【根据addressList中的数据排序】进行优先级排序吗,
想请教下,使用example里dubbo的server提供provider,在java里使用dubbo框架,能调用么。不知道是不是方式不对,我试了不行,还是说java也需要sofa框架的dubbo协议?
// sofa-rpc-node/lib/client/consumer.js 中
async _init() {
this._addressGroup = this.createAddressGroup(this.id + '@' + this.group);
if (this.options.serverHost) {
const addressList = this.options.serverHost.split(',').map(url => this.parseUrl(url));
setImmediate(() => { this._addressGroup.addressList = addressList; });
} else {
await this.registry.ready();
this._addressGroup = this.createAddressGroup(this.id + '@' + this.group);
this._addressListener = addressList => {
// addressList 为 []
this._addressGroup.addressList = addressList.map(url => this.parseUrl(url));
};
this.registry.subscribe(this.registryConfig, this._addressListener);
}
await this._addressGroup.ready();
}
async getConnection(req) {
return await this._addressGroup.getConnection(req);
}
时返回 null
想知道为什么 addressList 是空的?
集成 dubbo 时,直连服务是可以的,但是通过注册中心就不成功了
还有 group 的设置貌似不成功,直连的时候我需要将 group 名字写在 interfaceName 里面才行,单独配置 group 或者在初始化 client 时设置 group 都不成功
需求:客户端能够获取服务端返回的meta信息
在client端,直接抛出了最终的res.data的结果,而没抛出其中的res.meta
GRPC模块在使用时存在内存泄漏问题,问题发现为nodejs的http2模块问题。
在此提出issue标记一下该问题,提醒被内存泄漏困扰的开发。issue地址:
nodejs/node#28088
支持Nacos作为注册中心,目前仅支持zk,局限性太大。不知道仓库是否还在维护?
Describe the bug
A clear and concise description of what the bug is.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Smartphone (please complete the following information):
Additional context
Add any other context about the problem here.
服务端使用默认hessian3序列化版本,用node客户端去调用服务端,服务端可以正常接收请求,并返回,
但是当服务端hessian版本换成4的话,使用原来的node代码去调用的时候,出现异常,服务端未收到请求,我猜是序列化的问题,以下是错误日志:
,寻求专业解答。
使用sofa-boot-rpc发布的服务,注册到注册中心后,sofa-rpc-node客户端是否可以调用已注册的服务
大概什么时间会开放关于eggjs的插件
container 的网络
eth0 Link encap:Ethernet HWaddr 02:42:0A:FF:01:96
inet addr:10.255.1.150 Bcast:10.255.255.255 Mask:255.255.0.0
UP BROADCAST RUNNING MULTICAST MTU:1450 Metric:1
RX packets:164 errors:0 dropped:0 overruns:0 frame:0
TX packets:118 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:18204 (17.7 KiB) TX bytes:16597 (16.2 KiB)
eth1 Link encap:Ethernet HWaddr 02:42:0A:00:2B:81
inet addr:10.0.43.129 Bcast:10.0.43.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1450 Metric:1
RX packets:994842 errors:0 dropped:0 overruns:0 frame:0
TX packets:1557577 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:88179528 (84.0 MiB) TX bytes:124562996 (118.7 MiB)
eth0 被自动注册到zookeeper去了, 但是只有eth1 才能够顺利访问。
如何在注册的时候选择注册哪个网络啊?
gxcsoccer 你好
我这边在实际使用的时候有一个小问题,我的服务器有多块网卡,并不能实际的准确指定服务的ip,
能否在rpcServer初始化的时候指定服务ip呢?
类似这样,
// 2. 创建 RPC Server 实例
const server = new RpcServer({
logger,
registry, // 传入注册中心客户端
port: 12200,
// 传入本机ip
ip?: 192.168.1.1
});
谢谢
Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
Describe the solution you'd like
A clear and concise description of what you want to happen.
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.
nodejs.TypeError: Cannot read property 'hostname' of null
Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
Describe the solution you'd like
A clear and concise description of what you want to happen.
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.
node ts 描述参数类
export interface AppPermissionListVo {
/**
* 路由LIST
*/
permissions: Array<AppPlatformPermissionVo>;
}
参数只包装了父级 cn.bhbapp.vo.platform.AppPermissionListVo
于是调用时,AppPlatformPermissionVo
解析报错,转换异常。
Hi, I'm the author of Wildcard API and I've been wondering what you think of it?
问题一:consumer invoke 无法 ready 时,因为会不断 push 回调函数到数组中,所以会造成内存泄露,ready 的执行在这里
问题二:客户端可能会设置 responseTimeout,但如果无法 ready 时就会超过这个 timeout 的时间,客户端不好处理一些超时问题
研究一下 opossum,对比现在的实现,如果更优秀的话,考虑替换
https://schd.ws/hosted_files/jsi2018/bf/Fail_Faster-Adding_Circuit_Breakers_to_your_APIs.pdf
Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
Describe the solution you'd like
A clear and concise description of what you want to happen.
因为注册中心用的Nacos,如果要用Zookeeper还得单独部署zookeeper,或者自己用直连模式,根据Nacos注册的情况,手动负载均衡,如果提供个Nacos的NacosRegister,少写很多代码
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.