bitmex-client-websocket
bitmex-client-websocket copied to clipboard
Feature/multiplexing support
Hello everyone,
I'm working on a project where I needed multiplexing support from bitmex, so I wrote a quick adapter in order to support such feature on this library. Note that it's a quick implementation due my own project deadlines.
- Moved
HandleObjectMessageandHandleRawMessageto a global static class in order to reuse those handlers. - Added classes like
BitmexWebsocketChannelwhich represents a multiplexing channel,MultiplexingMessageBasefor the message structure orBitmexMultiplexClientused to send/receive data.
Next steps:
- I couldn't finish the Sample project showing how the multiplexing works, only recent trades are currently working. I'll try to fix it in the upcoming days.
- Add the required functionality to control how many users can be connected to the same multiplexing websocket and handle disconnections/errors (I've emailed bitmex and they said the limit is 1000 users) (They also recommended staying below 100 per socket/ip address if possible).
- The class naming (BitmexMultiplexClient) might not be ideal, check class names.
- Would be great to find a common abstraction between
BitmexWebsocketClientandBitmexMultiplexClientsince both represent a BitmexWebsocket but with different capabilities common interface).
Hello,
thanks, seems reasonable. Is it going to be backward compatible or brings any breaking change to usage? Ping me when you will be ready, I will go through it.
I would suggest to name it like BitmexWebsocketMultiplexClient, quite long, but more expressive.
Hello Marfusios,
I'm currently in holidays so I'll try to finish the tests as soon as I'm back home.
There shouldn't be any breaking change since the multiplex client is completely separated from the normal one.
Btw I like your name suggestion, I'll change it soon :)
Regards
Hi Marfusios Is this feature going to be added to the master branch? Thanks in advance Regards
Hi all! As I understood, this pr implementation wouldn't work, cause we can not subscribe to observable through another parent observable as tried in example:
client.Channels.Subscribe(channel =>
channel.Streams.InfoStream.Subscribe(info =>
{
Log.Information($"Channel = {channel.ChannelName} | Reconnection happened, Message: {info.Info}, Version: {info.Version:D}");
}));
@Marfusios, what you think about adding an optional field with info about channel and adding it to base response on handling?
Hi @ridicoulous,
Doesn't it work? I believe that it worked when I wrote the sample project.
Not gonna lie, had to implement this feature quick for a test project I was working on and didn't put much love into it, I might need to review all the changes again.
Thanks for the feedback!
Hi @BSanchidrian. It general it works fine, if we talk anout sending and receiving messages in communicator.
It does not work for me if I try create a subscribtion through client.Channels observable to each channel's stream as mentioned in example:
client.Channels.Subscribe(channel =>
channel.Streams.SubscribeStream.Subscribe(x =>
{
Log.Information(x.IsSubscription
? $"[{channel.ChannelName}]: Subscribed ({x.Success}) to {x.Subscribe}"
: $"[{channel.ChannelName}]:Unsubscribed ({x.Success}) from {x.Unsubscribe}");
}));
client.Channels.Subscribe(channel =>
channel.Streams.PongStream.Subscribe(x =>
Log.Information($"[{channel.ChannelName}] Pong received ({x.Message})")));
I mean that I can see messages in verbose logs of communicator, but didn't see messages from subscribtion in example
That's interesting, I'll definitely take a look whenever I have some free time.
Thanks @ridicoulous!
Unfortunately, I have a lack of time, let me check the current code later this week.
Hello @BSanchidrian , First of all thank you for your effort. A lot of time has passed. What stage is your work? Can we use this feature right now? I would be glad if you give information. :))