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

Socket ended automatically #2

Open
rymnc opened this issue Jan 14, 2021 · 0 comments
Open

Socket ended automatically #2

rymnc opened this issue Jan 14, 2021 · 0 comments

Comments

@rymnc
Copy link

rymnc commented Jan 14, 2021

Hi,
Usecase: Connect to websocket server, send subscription payload, and wait for replies

  while let Some(msg) = socket.recv().await {
    match msg {
      Msg::Text(msg) => println!("{}", decode_msg_to_json(msg.as_bytes().to_vec())),
      Msg::Binary(msg) => { //do stuff with binary
          }
          _ => println!("Other"),
        }
      }

The above is the code I've used, socket is of type Socket
The issue is that, it only gets one response and exits.
Upon investigation, it was due to the socket being closed. This script works for some websocket servers, but not for this one. I have used a synchronous websocket library to test the websocket server, and it has no issue.

Awaiting your reply

Update:
I modified this match in the lib.rs file recv_one

image

error code returned is 1002, which means malformed request.

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

1 participant