Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

example目录下的示例中的build.rs怎么才能运行生成src/greeter/server.rs等文件? #192

Open
fengnex opened this issue Apr 16, 2024 · 16 comments

Comments

@fengnex
Copy link

fengnex commented Apr 16, 2024

如题,示例文档没法用
example跑步起来。。。。。。。。。。。

对示例项目运行cargo build不会自动生成
`[package]
name = "dubbo1"
version = "0.1.0"
edition = "2021"

See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[[bin]]

name = "greeter-server"

path = "src/greeter/server.rs"

[[bin]]

name = "greeter-client"

path = "src/greeter/client.rs"

[dependencies]
http = "1.0.0"
http-body = "1.0.0"
futures-util = {version = "0.3", default-features = false}
tokio = { version = "1.0", features = [ "rt-multi-thread", "time", "fs", "macros", "net", "signal"] }
prost-derive = {version = "0.12.2", optional = true}
prost = "0.12.2"
async-trait = "0.1.56"
tokio-stream = "0.1"

dubbo = "0.3.0"
dubbo-config = "0.3.0"

[build-dependencies]

dubbo-build = "0.3.0"

dubbo-build = {git = "https://github.com/yang20150702/dubbo-rust.git"}`
[build-dependencies]的上面2个选项都不行

@fengnex
Copy link
Author

fengnex commented Apr 16, 2024

直接在github上下载的dubbo-rust-main目录下执行cargo build可以解决上面的问题。但问题是在dubbo-rust-main之外新建的项目,怎么通过才能对proto文件生产源码?这里主要是dubbo-build这个工具看起来没有起作用或无法自动运行----这个才是是上面的问题。

@fengnex
Copy link
Author

fengnex commented Apr 16, 2024

基于dubbo-rust-main在一台机器上运行greeter示例的服务端和客户端,nacos在本地以standalone模式运行,但是client遇到了下面的错误,二者还是不能正常通信,请教怎么解决:
INFO dubbo::triple::transport::connector::http_connector:84: host is ip address: "0.0.0.0" thread 'main' panicked at dubbo\src\triple\transport\connection.rs:104:50: called Result::unwrap()on anErrvalue: hyper::Error(Connect, Os { code: 10049, kind: AddrNotAvailable, message: " 在其上下文中,该请求的地址无效。" }) note: run withRUST_BACKTRACE=1 environment variable to display a backtrace

@onewe
Copy link
Contributor

onewe commented Apr 16, 2024

目前 还在完善中, 不好意思😬

@fengnex
Copy link
Author

fengnex commented Apr 16, 2024

理解,期待早日迈向成熟,更新相关文档。
这个示例现在必须要有nacos才能启动,但启动nacos后还是有问题,很遗憾。
看来目前nacos还是应以java、go版本为主。

@onewe
Copy link
Contributor

onewe commented Apr 16, 2024

目前活跃的开发者不多, 所以进度比较缓慢. 感谢理解.

@fengnex
Copy link
Author

fengnex commented Apr 16, 2024

看了一部分代码,能发展到现在必须说已经挺好了!
相信这个项目一定会越来越好!
因为rust的优点和dubbo3的一些良好特性,这个项目一定会前景广阔的!

@yang20150702
Copy link
Member

@fengnex
example下的 echo 例子是可以正常运行,该example没有使用服务发现。你可以试一下这个例子
对于nacos的报错,我们需要本地复现一下

@yang20150702
Copy link
Member

直接在github上下载的dubbo-rust-main目录下执行cargo build可以解决上面的问题。但问题是在dubbo-rust-main之外新建的项目,怎么通过才能对proto文件生产源码?这里主要是dubbo-build这个工具看起来没有起作用或无法自动运行----这个才是是上面的问题。

建议您先熟悉一下 echo 例子。可以直接clone源代码,在本地运行example。
对于您的问题,我简单介绍一下使用dubbo-rust进行rpc服务开发流程:

  1. cargo new echo:创建 cargo package
  2. 新增目录 protos,添加定义好的proto文件
  3. 在包的根目录下,新增 build.rs,用来compile proto文件来生成对应的rust代码。注意:需要预先在本地安装 protoc
  4. 我们在echo和greeter中提供了两种方案来use proto对应的rust代码,具体可以看代码
  5. 先实现Server,然后实现Client

参考:
https://doc.rust-lang.org/cargo/reference/build-scripts.html : build.rs文件会优先执行
https://github.com/protocolbuffers/protobuf#protobuf-compiler-installation

@fengnex
Copy link
Author

fengnex commented Apr 19, 2024

@yang20150702 现在版本的greeter示例已经能正常编译了,需要用到nacos,greeter服务也能注册到nacos,但是greeter-client不能与greeter-server通信,错误信息是:
dubbo::triple::transport::connector::http_connector:84: host is ip address: "0.0.0.0"
thread 'main' panicked at dubbo\src\triple\transport\connection.rs:104:50:
called Result::unwrap() on an Err value: hyper::Error(Connect, Os { code: 10049, kind: AddrNotAvailable, message: " 在其上下文中,该请求的地址无效。" })
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
不是你说的那些。

@onewe
Copy link
Contributor

onewe commented Apr 19, 2024

我直接在项目中运行 greeter 好像没有复现您说的问题,
image
给我们一点时间, 我们正在完善, 抱歉.

@fengnex
Copy link
Author

fengnex commented Apr 19, 2024

echo这个示例写的挺好的,验证通过。但是在Windows10上验证echo-tls时,echo-tls-server.exe和echo-tls-client.exe都能编译出来,把server.crt和ca.crt都添加到系统信任根证书中,echo-tls-server.exe提示server starting. addr: 127.0.0.1:8889,看起来运行正常,但是运行echo-tls-client.exe时报下面的错,请教该怎么解决:
RoutesFutureInnerState::Future
' panicked at dubbo\src\registry\registry.rs:78:63:
called Option::unwrap() on a None value
registry extension load failed.

@fengnex
Copy link
Author

fengnex commented Apr 19, 2024

@onewe 刚才重试了下,greeter示例能编译成功,服务端看起来能正常运行,但是运行客户端时报下面的错误,二者还是不能正常通信:
INFO dubbo::triple::transport::connector::http_connector:84: host is ip address: "0.0.0.0"
thread 'main' panicked at dubbo\src\triple\transport\connection.rs:104:50:
called Result::unwrap() on an Err value: hyper::Error(Connect, Os { code: 10049, kind: AddrNotAvailable, message: "在其上下文中,该请求的地址 无效。" })
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
这个错误跟上一次的一样,而且二者的编译、运行环境不同,2个环境应该可以证明这个问题了。

@bajie-git
Copy link

我是用Zookeeper也有同样的问题,server端可以正常启动,但dubbo admin上只能看到服务看不到方法。client请求的时候提示
called Result::unwrap() on an Err value: hyper::Error(Connect, Os { code: 10049, kind: AddrNotAvailable, message: "在其上下 文中,该请求的地址无效。" })
image

@bajie-git
Copy link

现在示例中最新版是v0.4.0,运行的时候报错:

error[E0407]: method `request_resource` is not a member of trait `crate::common::remote::grpc::message::GrpcRequestMessage`
 --> C:\Users\17274\.cargo\registry\src\mirrors.aliyun.com-8754fae0eb2f08f1\nacos-sdk-0.3.6\src\common\remote\grpc\message\request\client_detection_request.rs:3:1
  |
3 | #[request(identity = "ClientDetectionRequest", module = "internal")]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a member of trait `crate::common::remote::grpc::message::GrpcRequestMessage`
  |
  = note: this error originates in the attribute macro `request` (in Nightly builds, run with -Z macro-backtrace for more info)

我觉得是nacos-sdk 与 nacos-macro两个库不兼容导致的,nacos-sdk库common::remote::grpc::message::GrpcRequestMessage trait 并没有 request_resource 方法,但nacos-macro在实现他

@wfeii1980
Copy link

wfeii1980 commented Dec 17, 2024

现在示例中最新版是v0.4.0,运行的时候报错:

error[E0407]: method `request_resource` is not a member of trait `crate::common::remote::grpc::message::GrpcRequestMessage`
 --> C:\Users\17274\.cargo\registry\src\mirrors.aliyun.com-8754fae0eb2f08f1\nacos-sdk-0.3.6\src\common\remote\grpc\message\request\client_detection_request.rs:3:1
  |
3 | #[request(identity = "ClientDetectionRequest", module = "internal")]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a member of trait `crate::common::remote::grpc::message::GrpcRequestMessage`
  |
  = note: this error originates in the attribute macro `request` (in Nightly builds, run with -Z macro-backtrace for more info)

我觉得是nacos-sdk 与 nacos-macro两个库不兼容导致的,nacos-sdk库common::remote::grpc::message::GrpcRequestMessage trait 并没有 request_resource 方法,但nacos-macro在实现他

确实 把nacos-sdk升级到0.4.2就可以编译过去,一共两处。nacos-sdk的作者对nacos-macro的版本维护似乎有点问题。

@wfeii1980
Copy link

nacos-sdk已经修复了这个问题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants