websockets-rs / rust-websocket

A WebSocket (RFC6455) library written in Rust
http://websockets-rs.github.io/rust-websocket/
MIT License
1.55k stars 223 forks source link

How to send and receive messages in parallel? #177

Closed avkonst closed 5 years ago

avkonst commented 6 years ago

I have connected to wss using secure connection. Split() is not available in this case. But I need to write to and read from websocket client in parallel without blocking write by read ops. How can I achieve this?

vi commented 6 years ago

It was errorneously available before, but now is gone.

In async mode it works although. Have you tried the async example? It returns Framed which should contain split unconditionally.

Do you need some special example where sending and receiving happens simultaneously?

avkonst commented 6 years ago

Does it also work if it is secure channel?

On Sun, 15 Jul 2018, 07:26 Vitaly Shukela, notifications@github.com wrote:

It was errorneously available before, but now is gone.

In async mode it works although. Have you tried the async example https://github.com/websockets-rs/rust-websocket/blob/master/examples/async-client.rs? It returns Framed https://docs.rs/tokio-io/0.1.5/tokio_io/codec/struct.Framed.html which should contain split unconditionally.

Do you need some special example where sending and receiving happens simultaneously?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/websockets-rs/rust-websocket/issues/177#issuecomment-405044540, or mute the thread https://github.com/notifications/unsubscribe-auth/ADyZVTHJn46ytKxkuNyO0EYfNbmwIMlxks5uGkXRgaJpZM4Uxlk8 .

vi commented 6 years ago

As I said, it should contains split unconditionally (both for async_connect_secure and async_connect_insecure).

Have you already tried, but failed to do it?

At least in my own program I use split after universal connect.

avkonst commented 6 years ago

I have tried secure sync. Split function was not available. Maybe something has changed since then or it is different for async example. Thanks. I will try.

On Sun, 15 Jul 2018, 09:57 Vitaly Shukela, notifications@github.com wrote:

As I said, it should contains split unconditionally (both for connect_secure and connect_insecure).

Have you already tried, but failed to do it?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/websockets-rs/rust-websocket/issues/177#issuecomment-405052411, or mute the thread https://github.com/notifications/unsubscribe-auth/ADyZVYJ_Wv6SxxTaswgvCvarIkoD4c4Lks5uGmktgaJpZM4Uxlk8 .

vi commented 6 years ago

Maybe something has changed since then

Unlikely.

or it is different for async example

Likely.

kpp commented 5 years ago

@avkonst take a look at https://github.com/websockets-rs/rust-websocket/blob/master/examples/ssl-client.rs#L53

kpp commented 5 years ago

Would you please close this issue as resolved?

vi commented 5 years ago

@kpp, Do you maybe want to help maintain rust-websocket project in general?

Currently it is semi-abandoned.

kpp commented 5 years ago

Well, I might help to resolve some issues, but I am not going to maintain it forever =)