1

I am trying to get a Rust WebSocket server up and running. I started with the example code for an async websocker server.

Every time I get an Io error, like when the connection is interrupted, the entire program ends without any error. I modified the code on line 26 of the example to:

.map_err(|InvalidConnection {error, ..}| {
    println!("Error:{:?}",error);
    return error;
})

This prints the error, but does not prevent the program from stopping only the single connection and not crashing itself.

The most common error I get is:

Io(Error { repr: Custom(Custom { kind: Other, error: Stream(Error { repr: Custom(Custom { kind: ConnectionAborted, error: StringError("unexpected EOF observed") }) }) }) })
3
  • But what is your question ? Commented Jul 7, 2017 at 15:12
  • How to handle the Io Error so my program does not die and drops all other connections... Commented Jul 7, 2017 at 15:17
  • @Hahihula Please edit your question to clearly ask it. A question without highlighted and clear interrogation is not good in Stackoverflow. Commented Jul 7, 2017 at 15:34

1 Answer 1

0

Ok, with some help from rust IRC channel i found the solution. I've just replaced the error with None and filtered it out.

.map(Some).or_else(|_| -> Result<_, ()> { Ok(None) }).filter_map(|x| x) 

Maybe this info will help someone with similar problem.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.