Websocket: cannot subscribe with authentication
See original GitHub issueHi!
Without authentication, I can subscribe to GDAX Websocket feed (any channel combination).
Instead, if I set my key, passphrase and secret code, then I get the answer:
{"type":"error","message":"Sorry, you could not be authenticated: Bad Request","reason":"invalid signature"}
According to the GDAX api, when specifying channels you must authenticate using the path: "/users/self/verify"
(just "/users/self"
if you don’t specify channels).
However in signObject()
on WebsocketFeed.java
, the path is “” as you might find on line 198:
jsonObj.setSignature(signature.generate("", "GET", jsonString, timestamp));
I tried to correct the issue (i.e. setting the correct path), with no success.
Issue Analytics
- State:
- Created 6 years ago
- Comments:7
Top Results From Across the Web
Unable to authenticate connections to websocket gateways
In my use case the client will only be subscribing to messages and not pushing any messages at all. I could call client.disconnect()...
Read more >html - Websocket authentication - Stack Overflow
I'm running a websocket server and asking myself, if it's planed, that clients authentication will be done with handshake in future... draft xxxx...
Read more >Subscriptions in Apollo Server - Apollo GraphQL Docs
Enabling subscriptions ; 1. // Creating the WebSocket server ; 2. const wsServer = new WebSocketServer({ ; 3. // This is the `httpServer`...
Read more >Using STOMP JS
The STOMP Broker · Include STOMP.js · Create a STOMP client · Connection to the server · Heart-beating · Auto Reconnect · Send...
Read more >WebSocket Security - Heroku Dev Center
The WebSocket protocol doesn't handle authorization or authentication. Practically, this means that a WebSocket opened from a page behind auth ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I managed to solve this issue with the following changes:
requestPath
should be/users/self/verify
here: https://github.com/irufus/gdax-java/blob/master/src/main/java/com/coinbase/exchange/api/websocketfeed/WebsocketFeed.java#L198Subscribe.apiKey
field should be justkey
https://github.com/irufus/gdax-java/blob/eca981b0728673ffe033c22d1e21d72c77c56c55/src/main/java/com/coinbase/exchange/api/websocketfeed/message/Subscribe.java#L15 @irufus something that can be easily fixed @patrickjm @petnnw might be interested in this as well.Make these changes, then subscribe to
user
channel, and you are good to go.@robevansuk Your code works well for the market data, because it does not need authentication. If you would try to subscribe to the full channel with something like
{“type”:“subscribe”, “channels”:[{“name”:“user”,“product_ids”:[“ETH-DAI”,“ETH-USDC”,“BAT-ETH”]}], “signature”:“<signature>”, “passphrase”:“<phrase>”, “timestamp”:“<tstamp>”, “key”:“<key>” }
you can quickly realize (even after inserting your valid credentials in the above JSON), that upon subscription you will receive:
{“type”:“error”,“message”:“Authentication Failed”,“reason”:“{"message":"invalid signature"}”}
I also had the problems when I started to build an automated java trader, I have checked the code in node.js/javascript-api client to solve this issue and came to the same solution as @zoltanmajzik … and I am running my code with real money since month now.