GithubHelp home page GithubHelp logo

Comments (16)

roosglades avatar roosglades commented on June 20, 2024 2

I was getting them for REST. I updated to 1.1.3 and it seemed to resolved the issue.

from coinbase-advanced-py.

vinooganesh avatar vinooganesh commented on June 20, 2024 1

Hi @urischwartz-cb -I'm getting this issue fairly frequently and sporadically as well. Is there any guidance to resolve this? The responses are unquestionably inconsistent. Meaning, I'll get a working response, make no code changes, run it again and see a failure.

Not working:

2024-02-08 22:16:46 - coinbase.WSClient - DEBUG - Successfully connected to wss://advanced-trade-ws.coinbase.com/
2024-02-08 22:16:46 - coinbase.WSClient - DEBUG - Subscribing to channel ticker for product IDs: ['BTC-USD']
2024-02-08 22:16:46 - coinbase.WSClient - DEBUG - Successfully subscribed
{"type":"error","message":"authentication failure"}
2024-02-08 22:16:51 - coinbase.WSClient - DEBUG - Unsubscribing from channel ticker for product IDs: ['BTC-USD']
2024-02-08 22:16:51 - coinbase.WSClient - DEBUG - Successfully unsubscribed
2024-02-08 22:16:51 - coinbase.WSClient - DEBUG - Closing connection to wss://advanced-trade-ws.coinbase.com
2024-02-08 22:16:51 - coinbase.WSClient - DEBUG - Connection closed to wss://advanced-trade-ws.coinbase.com/
2024-02-08 22:16:51 - coinbase.WSClient - DEBUG - Connection closed (OK): sent 1000 (OK); then received 1000 (OK)

No code change. Working:

2024-02-08 22:17:49 - coinbase.WSClient - DEBUG - Successfully connected to wss://advanced-trade-ws.coinbase.com/
2024-02-08 22:17:49 - coinbase.WSClient - DEBUG - Subscribing to channel ticker for product IDs: ['BTC-USD']
2024-02-08 22:17:49 - coinbase.WSClient - DEBUG - Successfully subscribed
{"channel":"ticker","client_id":"","timestamp":"2024-02-09T03:17:49.000088799Z","sequence_num":0,"events":[{"type":"snapshot","tickers":[{"type":"ticker","product_id":"BTC-USD","price":"46221.86","volume_24_h":"19480.95913896","low_24_h":"44419.36","high_24_h":"46395.33","low_52_w":"19568.52","high_52_w":"49102.29","price_percent_chg_24_h":"3.45659138797705"}]}]}

{"channel":"subscriptions","client_id":"","timestamp":"2024-02-09T03:17:49.000106727Z","sequence_num":1,"events":[{"subscriptions":{"ticker":["BTC-USD"]}}]}
{"channel":"ticker","client_id":"","timestamp":"2024-02-09T03:17:49.020993024Z","sequence_num":2,"events":[{"type":"update","tickers":[{"type":"ticker","product_id":"BTC-USD","price":"46223.75","volume_24_h":"19480.95913896","low_24_h":"44419.36","high_24_h":"46395.33","low_52_w":"19568.52","high_52_w":"49102.29","price_percent_chg_24_h":"3.46082170146342"}]}]}
...

@urischwartz-cb what information can I get you to help you debug? This almost looks like a rate limit of some sort.

from coinbase-advanced-py.

vinooganesh avatar vinooganesh commented on June 20, 2024 1

@urischwartz-cb sure, here you go:

Not working:

2024-02-09 11:35:12 - coinbase.WSClient - DEBUG - Connecting to wss://advanced-trade-ws.coinbase.com
2024-02-09 11:35:12 - coinbase.WSClient - DEBUG - Successfully connected to wss://advanced-trade-ws.coinbase.com/
2024-02-09 11:35:12 - coinbase.WSClient - DEBUG - Subscribing to channel ticker for product IDs: ['BTC-USD']
2024-02-09 11:35:12 - coinbase.WSClient - DEBUG - Successfully subscribed
{"type":"error","message":"authentication failure"}
2024-02-09 11:35:17 - coinbase.WSClient - DEBUG - Unsubscribing from channel ticker for product IDs: ['BTC-USD']
2024-02-09 11:35:17 - coinbase.WSClient - DEBUG - Successfully unsubscribed
2024-02-09 11:35:17 - coinbase.WSClient - DEBUG - Closing connection to wss://advanced-trade-ws.coinbase.com
2024-02-09 11:35:17 - coinbase.WSClient - DEBUG - Connection closed to wss://advanced-trade-ws.coinbase.com/
2024-02-09 11:35:17 - coinbase.WSClient - DEBUG - Connection closed (OK): sent 1000 (OK); then received 1000 (OK)

Working:

2024-02-09 11:35:23 - coinbase.WSClient - DEBUG - Connecting to wss://advanced-trade-ws.coinbase.com
2024-02-09 11:35:23 - coinbase.WSClient - DEBUG - Successfully connected to wss://advanced-trade-ws.coinbase.com/
2024-02-09 11:35:23 - coinbase.WSClient - DEBUG - Subscribing to channel ticker for product IDs: ['BTC-USD']
2024-02-09 11:35:23 - coinbase.WSClient - DEBUG - Successfully subscribed
{"channel":"ticker","client_id":"","timestamp":"2024-02-09T16:35:23.078573291Z","sequence_num":0,"events":[{"type":"snapshot","tickers":[{"type":"ticker","product_id":"BTC-USD","price":"47235.08","volume_24_h":"20396.14292071","low_24_h":"44893.21","high_24_h":"47723.78","low_52_w":"19568.52","high_52_w":"49102.29","price_percent_chg_24_h":"4.52438112532084"}]}]}
...
2024-02-09 11:35:28 - coinbase.WSClient - DEBUG - Unsubscribing from channel ticker for product IDs: ['BTC-USD']
2024-02-09 11:35:28 - coinbase.WSClient - DEBUG - Successfully unsubscribed
2024-02-09 11:35:28 - coinbase.WSClient - DEBUG - Closing connection to wss://advanced-trade-ws.coinbase.com
2024-02-09 11:35:28 - coinbase.WSClient - DEBUG - Connection closed to wss://advanced-trade-ws.coinbase.com/
2024-02-09 11:35:28 - coinbase.WSClient - DEBUG - Connection closed (OK): sent 1000 (OK); then received 1000 (OK)

Code:

from coinbase.websocket import (WSClient, WSClientConnectionClosedException,
                                WSClientException)
import time
ws_client = WSClient(key_file="./coinbase-sdk/coinbase_cloud_api_key.json", on_message=on_message, verbose=True)
try:
    ws_client.open()
    ws_client.ticker(product_ids=["BTC-USD"])
    time.sleep(5)
    ws_client.ticker_unsubscribe(product_ids=["BTC-USD"])
    ws_client.close()
except WSClientConnectionClosedException as e:
    print("Connection closed! Retry attempts exhausted.")
except WSClientException as e:
    print("Error encountered!")

from coinbase-advanced-py.

urischwartz-cb avatar urischwartz-cb commented on June 20, 2024 1

@vinooganesh we just pushed a change that should solve the problem for the WSClient. It does seem to have been a clock skew issue. Please let me know if it is resolved.
We will push out a similar fix for REST connections on Monday. Thanks for your feedback and for helping us improve our product!

from coinbase-advanced-py.

vinooganesh avatar vinooganesh commented on June 20, 2024 1

@urischwartz-cb - Thanks for all of your help here! It looks good from my end now.

from coinbase-advanced-py.

github-actions avatar github-actions commented on June 20, 2024

Thank you for reporting! If this is an SDK specific issue, we will look into it and get back to you soon. If this is an API related request, report it in our Advanced API forum instead.

from coinbase-advanced-py.

urischwartz-cb avatar urischwartz-cb commented on June 20, 2024

Hi @camandrewz, thanks for flagging. Has this been resolved? We were able to see you successfully making requests throughout the day. If not you can create a support ticket here and we can help you more directly.

from coinbase-advanced-py.

urischwartz-cb avatar urischwartz-cb commented on June 20, 2024

Thank you for flagging! We will prioritize fixing this and get back to you if we need any information to help debug.

from coinbase-advanced-py.

vinooganesh avatar vinooganesh commented on June 20, 2024

Thanks! Out of curiosity, do you have any thoughts about what could be causing it? I'm wondering if I should move back to the regular rest endpoints for the time being, especially if the investigation may take some time.

from coinbase-advanced-py.

urischwartz-cb avatar urischwartz-cb commented on June 20, 2024

@vinooganesh we just pushed something that will help us identify the source of the unauth issues more clearly. Please retry using the WebSocket client and let me know timestamps of when the error occurred. Thank you!

from coinbase-advanced-py.

urischwartz-cb avatar urischwartz-cb commented on June 20, 2024

@vinooganesh we believe the issue stems from clock skew, since your request JWTs seem to have an expiry time that is greater than 2 minutes past when we receive your request.
Could you compare the output of your mahcine's time.time() vs hitting https://api.coinbase.com/v2/time please? Particularly in an example where the authentication fails. We would expect some divergence there.

from coinbase-advanced-py.

vinooganesh avatar vinooganesh commented on June 20, 2024

@urischwartz-cb, sure here you go

2024-02-09 13:40:42 - coinbase.WSClient - DEBUG - Connecting to wss://advanced-trade-ws.coinbase.com
2024-02-09 13:40:43 - coinbase.WSClient - DEBUG - Successfully connected to wss://advanced-trade-ws.coinbase.com/
2024-02-09 13:40:43 - coinbase.WSClient - DEBUG - Subscribing to channel ticker for product IDs: ['BTC-USD']
2024-02-09 13:40:43 - coinbase.WSClient - DEBUG - Successfully subscribed
time.time(): 1707504042.871829
Coinbase API time: {"data":{"iso":"2024-02-09T18:40:42Z","epoch":1707504042}}
{"type":"error","message":"authentication failure"}
2024-02-09 13:40:46 - coinbase.WSClient - DEBUG - Unsubscribing from channel ticker for product IDs: ['BTC-USD']
2024-02-09 13:40:46 - coinbase.WSClient - DEBUG - Successfully unsubscribed
2024-02-09 13:40:46 - coinbase.WSClient - DEBUG - Closing connection to wss://advanced-trade-ws.coinbase.com
2024-02-09 13:40:46 - coinbase.WSClient - DEBUG - Connection closed to wss://advanced-trade-ws.coinbase.com/
2024-02-09 13:40:46 - coinbase.WSClient - DEBUG - Connection closed (OK): sent 1000 (OK); then received 1000 (OK)

Updated code:

    print("time.time(): " + str(time.time()))
    print("Coinbase API time: " + requests.get("https://api.coinbase.com/v2/time").text)
    ws_client.open()
    ws_client.ticker(product_ids=["BTC-USD"])

from coinbase-advanced-py.

urischwartz-cb avatar urischwartz-cb commented on June 20, 2024

@vinooganesh we just pushed a change that will allow us to confirm the expiry time you are sending us in the failed requests. Please let me know once you are able to repro again and I will check this.
Thanks again for your patience as we work to figure this out.

from coinbase-advanced-py.

vinooganesh avatar vinooganesh commented on June 20, 2024

No problem @urischwartz-cb, here you go (Reproed a few times):

2024-02-09 16:39:00 - coinbase.WSClient - DEBUG - Connecting to wss://advanced-trade-ws.coinbase.com
time.time(): 1707514740.449631
Coinbase API time: {"data":{"iso":"2024-02-09T21:38:59Z","epoch":1707514739}}
2024-02-09 16:39:00 - coinbase.WSClient - DEBUG - Successfully connected to wss://advanced-trade-ws.coinbase.com
2024-02-09 16:39:00 - coinbase.WSClient - DEBUG - Subscribing to channel ticker for product IDs: ['BTC-USD']
2024-02-09 16:39:00 - coinbase.WSClient - DEBUG - Successfully subscribed
{"type":"error","message":"authentication failure"}
2024-02-09 16:39:03 - coinbase.WSClient - DEBUG - Unsubscribing from channel ticker for product IDs: ['BTC-USD']
2024-02-09 16:39:03 - coinbase.WSClient - DEBUG - Successfully unsubscribed
2024-02-09 16:39:03 - coinbase.WSClient - DEBUG - Closing connection to wss://advanced-trade-ws.coinbase.com
2024-02-09 16:39:03 - coinbase.WSClient - DEBUG - Connection closed to wss://advanced-trade-ws.coinbase.com/
2024-02-09 16:39:03 - coinbase.WSClient - DEBUG - Connection closed (OK): sent 1000 (OK); then received 1000 (OK)
2024-02-09 16:39:24 - coinbase.WSClient - DEBUG - Connecting to wss://advanced-trade-ws.coinbase.com
time.time(): 1707514763.8576
Coinbase API time: {"data":{"iso":"2024-02-09T21:39:23Z","epoch":1707514763}}
2024-02-09 16:39:24 - coinbase.WSClient - DEBUG - Successfully connected to wss://advanced-trade-ws.coinbase.com
2024-02-09 16:39:24 - coinbase.WSClient - DEBUG - Subscribing to channel ticker for product IDs: ['BTC-USD']
2024-02-09 16:39:24 - coinbase.WSClient - DEBUG - Successfully subscribed
{"type":"error","message":"authentication failure"}
2024-02-09 16:39:27 - coinbase.WSClient - DEBUG - Unsubscribing from channel ticker for product IDs: ['BTC-USD']
2024-02-09 16:39:27 - coinbase.WSClient - DEBUG - Successfully unsubscribed
2024-02-09 16:39:27 - coinbase.WSClient - DEBUG - Closing connection to wss://advanced-trade-ws.coinbase.com
2024-02-09 16:39:27 - coinbase.WSClient - DEBUG - Connection closed to wss://advanced-trade-ws.coinbase.com/
2024-02-09 16:39:27 - coinbase.WSClient - DEBUG - Connection closed (OK): sent 1000 (OK); then received 1000 (OK)
2024-02-09 16:39:42 - coinbase.WSClient - DEBUG - Connecting to wss://advanced-trade-ws.coinbase.com
2024-02-09 16:39:42 - coinbase.WSClient - DEBUG - Successfully connected to wss://advanced-trade-ws.coinbase.com/
2024-02-09 16:39:42 - coinbase.WSClient - DEBUG - Subscribing to channel ticker for product IDs: ['BTC-USD']
2024-02-09 16:39:42 - coinbase.WSClient - DEBUG - Successfully subscribed
time.time(): 1707514781.932235
Coinbase API time: {"data":{"iso":"2024-02-09T21:39:41Z","epoch":1707514781}}
{"type":"error","message":"authentication failure"}
2024-02-09 16:39:45 - coinbase.WSClient - DEBUG - Unsubscribing from channel ticker for product IDs: ['BTC-USD']
2024-02-09 16:39:45 - coinbase.WSClient - DEBUG - Successfully unsubscribed
2024-02-09 16:39:45 - coinbase.WSClient - DEBUG - Closing connection to wss://advanced-trade-ws.coinbase.com
2024-02-09 16:39:45 - coinbase.WSClient - DEBUG - Connection closed to wss://advanced-trade-ws.coinbase.com/
2024-02-09 16:39:45 - coinbase.WSClient - DEBUG - Connection closed (OK): sent 1000 (OK); then received 1000 (OK)

from coinbase-advanced-py.

roosglades avatar roosglades commented on June 20, 2024

were fixes committed to this issue? I am experiencing the same problem

from coinbase-advanced-py.

urischwartz-cb avatar urischwartz-cb commented on June 20, 2024

@roosglades We fixed the issue in the WebSocket service. A fix for the REST API is in our release queue. Are you still seeing issues with WebSocket or only REST?

from coinbase-advanced-py.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.