Skip to content

Close message different behaviour on Mac and Linux. #270

@Rohit171994

Description

@Rohit171994

i am implementing multi-threaded websocket client server chat application. On client side i am using rust-websocket library, while on the server side i am not using this library rather manually reading from the socket(TcpStream) connection.

On server side i am trying to read the data as let buf = socket.read_u16::<BigEndian>()?;
where read_u16 is from byteorder::io::ReadBytesExt.
it work fine for the text message sent by the client,
The issue starts when we try to close any client by sending close message to the server as below,

let close_msg = Message::close();
let res = sender.send_message(&close_msg);

while reading this message on server side, with let buf = socket.read_u16::<BigEndian>()?; , it is successful on mac, but while in Linux it fails with wouldblock error i.e:

thread 'tokio-runtime-worker' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 11, kind: WouldBlock, message: "Resource temporarily unavailable" }

On other hand if we send as close message using ping,

let close_msg = Message::ping(vec![1u8]);;
let res = sender.send_message(&close_msg);

then it don't give the above error and is successful on linux .
I didn't understand why it behave different on mac and linux , can anyone please help?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions