Skip to content

Problems with gdax websocket #27

@jamesalbert

Description

@jamesalbert

When trying to connect to GDAX's public websocket:

let ws = waitFor newAsyncWebsocket("wss://ws-feed.gdax.com:443/", 
                                   ctx=newContext(verifyMode=CVerifyNone))

I get Error: unhandled exception: server did not reply with a websocket upgrade: HTTP/1.1 520 Origin Error

Because I'm able to connect to wss://echo.websocket.org using the same function, and I'm able to connect using python (e.g. create_connection("wss://ws-feed.gdax.com:443/")), I suspect this is on websocket.nim's side. I've tried forking and fiddling around, but no dice

(I've tried it with both the production and sandbox feed)

edit: Forgot to post stats

  • OS: Ubuntu 16.04 (running in docker image nimlang/nim:latest)
  • websockets.nim: head

update: looking back at this, I see this is a CloudFlare specific error code:

While the 520 error can be triggered by very unique and strange edge-case scenarios, they are generally caused by:

Connection resets (following a successful TCP handshake)
Headers exceed Cloudflare’s header size limit (over 8kb)
Empty response from origin
Invalid HTTP response
HTTP response missing response headers

But again, I was able to connect to it successfully in python and bash:

$ curl --include \
     --no-buffer \
     --header "Connection: Upgrade" \
     --header "Upgrade: websocket" \
     --header "Host: ws-feed.gdax.com:443" \
     --header "Origin: http://example.com:80" \
     --header "Sec-WebSocket-Key: SGVsbG8sIHdvcmxkIQ==" \
     --header "Sec-WebSocket-Version: 13" \
     https://ws-feed.gdax.com:443/

HTTP/2 200
date: Tue, 30 Jan 2018 08:00:27 GMT
content-type: text/plain
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions