Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WampSharp unable to connect to Poloniex?

Tags:

c#

wamp

wampsharp

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?

like image 628
Arash Emami Avatar asked Jul 23 '16 00:07

Arash Emami


1 Answers

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.

like image 83
darkl Avatar answered Oct 21 '22 13:10

darkl