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") }) }) }) })
Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
Hahihula
  • 173
  • 3
  • 7

1 Answers1

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.

Hahihula
  • 173
  • 3
  • 7