Not receiving any messages on tokio-tungstenite stream

I started developing a websocket client with ws-rs but ran into issues with Windows compatibility (even with native-tls) and I saw that tokio-tungstenite was a much more active repo so I started the switch. My code compiles, but it seems as if I'm not receiving any messages on my stream.

I tried to follow this example as closely as I could, but I'm not having any luck and I'm not sure what the best way to debug is.

Generally what I'm trying to do is open a websocket connection, send a heartbeat message every 10 seconds, and parse incoming messages and print them to stdout. It seems like my messages are being sent properly (I've added some print statements), but I'm not receiving any messages from the websocket itself. I believe it should be receiving messages because the server is configured to shut down after a few minutes if it doesn't receive messages, but since I'm sending the heartbeat the server seems to stay alive.

Any help would be greatly appreciated!

EDIT: I figured this out - the code in the linked PR now works.

The issue was that my timer logic was a blocking loop, not an asynchronous loop. Moving to use the tokio::timer APIs resolved my issue.

1 Like