WampSharp unable to connect to Poloniex?

1.8k Views Asked by At

Here is my very simple code using the latest prerelease version of WampSharp:

        var channelFactory = new DefaultWampChannelFactory();
        var channel = channelFactory.CreateMsgpackChannel("wss://api.poloniex.com", "realm1");
        await channel.Open();

        var realmProxy = channel.RealmProxy;

        Console.WriteLine("Connection established");

        int received = 0;
        IDisposable subscription = null;

        subscription =
            realmProxy.Services.GetSubject("ticker")
                      .Subscribe(x =>
            {
                Console.WriteLine("Got Event: " + x);

                received++;

                if (received > 5)
                {
                    Console.WriteLine("Closing ..");
                    subscription.Dispose();
                }
            });

        Console.ReadLine();

Doesn't work though, the code within the subscription never runs. Tried it with CreateJsonChannel as well, that doesn't work either.

Any ideas what might be wrong?

1

There are 1 best solutions below

2
On

Your code works fine. Just get rid of the Console.ReadLine - it blocks the WebSocket thread and therefore WampSharp can't get any further messages. You can add a Console.ReadLine to your Main instead.

See also blog post.