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

WebSocket Example on homepage no longer working #122

Closed
xiaoas opened this issue Aug 11, 2022 · 4 comments
Closed

WebSocket Example on homepage no longer working #122

xiaoas opened this issue Aug 11, 2022 · 4 comments

Comments

@xiaoas
Copy link

xiaoas commented Aug 11, 2022

Describe the bug
I recently updated salvo from 1.16 to 1.29. Sadly my webSocket server would no longer compile.
So I went grab the example at the bottom of salvo homepage, that one ain't compiling as well.

Cargo.toml:

[package]
name = "noname-server"
version = "0.1.0"
edition = "2021"

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

[dependencies]
salvo = { version = "0.*", features = ["full"] }
tokio = { version = "1", features = ["full"] }
tokio-stream = "*"
futures = "*"
futures-util = "0.3"
once_cell = "1"
tracing = "0.1"
tracing-subscriber = "0.2.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1"
rand = "0.8"
thiserror = "1"

Error:

error[E0412]: cannot find type `HttpError` in this scope
 --> src/main.rs:6:71
  |
6 | async fn connect(req: &mut Request, res: &mut Response) -> Result<(), HttpError> {
  |                                                                       ^^^^^^^^^ not found in this scope

error[E0698]: type inside `async` block must be known in this context
 --> src/main.rs:5:1
  |
5 | #[handler]
  | ^^^^^^^^^^ cannot infer type
  |
note: the type is part of the `async` block because of this `await`
 --> src/main.rs:5:1
  |
5 | #[handler]
  | ^^^^^^^^^^
  = note: this error originates in the attribute macro `handler` (in Nightly builds, run with -Z macro-backtrace for more info)

Some errors have detailed explanations: E0412, E0698.
For more information about an error, try `rustc --explain E0412`.
error: could not compile `noname-server` due to 2 previous errors

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
The example should compile(hopefully).

Screenshots
image

Desktop (please complete the following information):

  • OS: macos
  • Version 0.29.1
@xiaoas xiaoas changed the title WebSocket Example on homepage non longer working WebSocket Example on homepage no longer working Aug 11, 2022
@xiaoas
Copy link
Author

xiaoas commented Aug 11, 2022

I tried https://github.com/salvo-rs/salvo/blob/main/examples/ws/src/main.rs

That one is working.🥲

@chrislearn
Copy link
Member

chrislearn commented Aug 11, 2022

You use salvo = { version = "0.*", features = ["full"] } here, can you confirm is latest salvo version is used? Please check your Cargo.lock

@chrislearn
Copy link
Member

Try change HttpError to StatusError.

@xiaoas
Copy link
Author

xiaoas commented Aug 11, 2022

You use salvo = { version = "0.*", features = ["full"] } here, can you confirm is latest salvo version is used? Please check your Cargo.lock

Yes I'm using the latest version of salvo.

Changing HttpError to StatusError fixes the issue.

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

2 participants