Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No WebSocket Response #296

Open
dsconsole283 opened this issue Oct 4, 2021 · 5 comments
Open

No WebSocket Response #296

dsconsole283 opened this issue Oct 4, 2021 · 5 comments

Comments

@dsconsole283
Copy link

Hello!

I just want to preface by letting you know that I am not very experienced in any of this...

Hopefully this isn't user error, but I can't seem to get a response from any event available with the websocket. I have received bid/ask information using the REST API (var result = await client.ProductsService.GetProductTickerAsync("ADA-USD");), but the websocket status only ever says "connecting" and never invokes any event. I guess my actual question is: has anything changed or are there any known issues as to why this may not be working? Or is this most likely an error on my part? Thanks for any help!

@dougdellolio
Copy link
Owner

hi @dsconsole283 the websocket seems to be working on my end. Here is an example snippet you can try. You should fill in the authenticator with your sandbox credentials and use the readme if you need some help with that.

(https://github.com/dougdellolio/coinbasepro-csharp#how-to-use)

Example code:

 public class Program
    {
        public static void Main(string[] args)
        {
            //fill this in with your own authenticator
            var authenticator = new Authenticator(...);

            //create the CoinbasePro client using the sandbox
            var coinbaseProClient = new CoinbaseProClient(authenticator, true);

            //subscribe to the ticker channel type
            var productTypes = new List<string> { "BTC-USD" };
            var channels = new List<ChannelType> { ChannelType.Full };

            var webSocket = coinbaseProClient.WebSocket;
            webSocket.Start(productTypes, channels);

            webSocket.OnDoneReceived += (sender, e) =>
            {
                Print(e);
            };

            Console.ReadKey();
        }

        private static void Print(WebfeedEventArgs<Done> webfeedEventArgs)
        {
            Console.WriteLine("OrderId = " + webfeedEventArgs.LastOrder.OrderId);
            Console.WriteLine("Price = " + webfeedEventArgs.LastOrder.Price);
            Console.WriteLine("Reason = " + webfeedEventArgs.LastOrder.Reason);
            Console.WriteLine("Remaining Size = " + webfeedEventArgs.LastOrder.RemainingSize);
            Console.WriteLine("Side = " + webfeedEventArgs.LastOrder.Side);

            Console.WriteLine("==============");
        }
    }

@dsconsole283
Copy link
Author

Thank you so much! I'll give it a try. It's strange because my code is similar except for the subscriber method.. I basically just cemented the understanding of events today, so I have some refining to do. Thanks again! PS I'm looking for a C# friend/mentor if anyone sees this and is generous enough to lend their time!

@dsconsole283
Copy link
Author

Not sure if this is the right spot for this, but I always eventually get this disconnect exception
Screenshot 2021-11-11 061508

It doesn't point to any lines in my own code, so I'm assuming it's an unhandled exception in the library??

@nickwhitley
Copy link

Hey @dsconsole283 you seem like a right ol' chum. I can mentor you in the world of programming. I am, as they say, an expert. A Grand Champ in programming if you will. So just let me know.

@prozerran
Copy link

As the library changed in anyway? It was working for several years and all of a sudden, i am not getting any websocket information for ticker. Here is the code, Was working before...

            //create the CoinbasePro client without an authenticator
            coinbaseProClient = new CoinbaseProClient();

            //use the websocket feed
            var productTypes = new List<string>() { "BTC-USD", "ETH-USD" };
            var channels = new List<ChannelType>() { ChannelType.Ticker }; // When not providing any channels, the socket will subscribe to all channels

            var webSocket = coinbaseProClient.WebSocket;
            webSocket.Start(productTypes, channels);

            // EventHandler for the heartbeat response type
            webSocket.OnTickerReceived += WebSocket_OnTickerReceived;

I am not getting any callbacks to WebSocket_OnTickerReceived anymore. Why is that? I am not using any authenticator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants