Push oriented protocol with Tokio


#1

I’m looking at implementing a client for a websocket-like protocol with Tokio, and I wonder if I have to roll my own protocol or if I can build on top of the ones from https://docs.rs/tokio-proto/0.1.1/tokio_proto/index.html

The protocol works as follows:

  • The client can “fire and forget” requests. Some will have matching responses, some not.
  • The server will push unsolicited packets to the client, similar to push notifications.

My understanding is that the tokio-proto protocols are very much bound to a request/response model and thus not applicable for me. Am I right?


#2

I am curious about this too.


#3

If you just want to build the client for your enjoyment please ignore my comment.

However, if you are looking for a solution for this problem have you looked into MQTT?
It is already implemented in C, and something also in Rust.

:beers:


#4

And what is wrong with simply using websockets?


#5

There is nothing wrong with MQTT or WebSockets, but in my case the server is not under my control, and is exposed on a Unix Domain Socket.

I went with implementing a Tokio codec and it’s working well enough for my purposes so far.


#6

Not under your control but you can pick the protocol. That sounds pretty odd. Nevertheless some web servers are able to listen on a unix domain sockets (like nginx), so websockets can still be used over uds.


#7

Trust me, I have no hope of changing anything on the server side. But that’s fine.