Handshake status 500 handshakefailed when running the markety_price.py example code.

Hi,

When running the Python code (I use Python) market_price.py from the WebSocket API Sample Applications (link) Iget the following:

Connecting to WebSocket ws://hostname:15000/WebSocket ...
Handshake status 500 handshakefailed
WebSocket Closed

I do have the market data server setup (ADS) within my environment that supports the WebSocket API and I am able to login via the interactive guide on the developer's portal.

Could anyone explain to me how this must be done correctly?

I fail to see what I should do other than setting the default global variables to my values and then run the code.

Thanks in advance,

I hope my question is sufficiently clear,

Best regards

Best Answer

  • nick.zincone
    Answer ✓

    Hi @mehdi.el.hamzaoui,

    If all other examples failed and it works in your browser only, there must be something different in the route of your access when you are in your browser. Confirm you are able to successfully send requests and receive responses in your browser just to make sure. Also, check your logs in the ADS for additional details related to your different tests. Confirm both the browser connection and application connects to compare.

Answers

  • Hi @mehdi.el.hamzaoui,

    Can you confirm which version of Python you are using? There are some specific instructions within the README file that you will need to pay attention to. For example:

    NOTE: The posting example must be run with Python3.0 or greater. The other 
    examples may be run with Python2.7 or greater.<br>

    And

    Run (in order):
    pip install requests
    pip install websocket-client
    (Only for Python versions less than 3.3) pip install ipaddress

    Also, you may be going through a proxy and within your browser, the setup may be different than running from a command window. You may need to confirm your network access.

  • Hi @nick.zincone.1 and thank you for your quick reply,

    I am using Python 3.6.5 and have indeed followed the instructions within the README file installing the above mentioned packages.

  • update: I tried running it in PyCharm but to no avail:

    Connecting to WebSocket ws://hostname:port/WebSocket ...<br>Handshake status 500 handshakefailed<br>WebSocket Closed
  • Hi @mehdi.el.hamzaoui,

    I didn't find much information on a WebSocket error status 500 other than issues related to network routes, proxy setting, etc. Is it possible for you to try one of the other examples? This may provide a clue as to whether the issue is related to your network setup and the route to ADS.

    In addition, find out if the ADS logs are showing any additional related to your connection.

  • Hi @nick.zincone.1 ,

    I have tried the other examples as well as disabled the firewall temporarily, but it did not help.

    Thanks anyway

  • Hello @mehdi.el.hamzaoui

    Did web browser interactive guide and Python application connect to the same ADS host and WebSocket port?

  • Yes, it did. However the issue has been solved. It was actually a problem with my machine.