Discover Refinitiv
MyRefinitiv Refinitiv Perspectives Careers
Created with Sketch.
All APIs Questions & Answers  Register |  Login
Ask a question
  • Questions
  • Tags
  • Badges
  • Unanswered
Search:
  • Home /
  • TREP Infrastructure /
avatar image
Question by Raghav Atal · Aug 17, 2021 at 08:04 PM · trepissueconnection-error

TREP Websocket connection issues : python example market_price.py unable to connect: Error 400

The example websocket python script connects after 7 or 8 tries. Please see below for logs

(tensorflow) C:\Users\Raghav.Atal\Documents\Developer\external_code_repos\websocket-api\Applications\Examples\python>python market_price.py --host trep-dacs-main.corp.stonex.com --user MDHUB

Connecting to WebSocket ws://trep-dacs-main.corp.stonex.com:15000/WebSocket ...

Handshake status 400 OK

on_close() takes 1 positional argument but 3 were given


(tensorflow) C:\Users\Raghav.Atal\Documents\Developer\external_code_repos\websocket-api\Applications\Examples\python>python market_price.py --host trep-dacs-main.corp.stonex.com --user MDHUB

Connecting to WebSocket ws://trep-dacs-main.corp.stonex.com:15000/WebSocket ...

Handshake status 400 OK

on_close() takes 1 positional argument but 3 were given


(tensorflow) C:\Users\Raghav.Atal\Documents\Developer\external_code_repos\websocket-api\Applications\Examples\python>python market_price.py --host trep-dacs-main.corp.stonex.com --user MDHUB

Connecting to WebSocket ws://trep-dacs-main.corp.stonex.com:15000/WebSocket ...

Handshake status 400 OK

on_close() takes 1 positional argument but 3 were given


(tensorflow) C:\Users\Raghav.Atal\Documents\Developer\external_code_repos\websocket-api\Applications\Examples\python>python market_price.py --host trep-dacs-main.corp.stonex.com --user MDHUB

Connecting to WebSocket ws://trep-dacs-main.corp.stonex.com:15000/WebSocket ...

Handshake status 400 OK

on_close() takes 1 positional argument but 3 were given


(tensorflow) C:\Users\Raghav.Atal\Documents\Developer\external_code_repos\websocket-api\Applications\Examples\python>python market_price.py --host trep-dacs-main.corp.stonex.com --user MDHUB

Connecting to WebSocket ws://trep-dacs-main.corp.stonex.com:15000/WebSocket ...

Handshake status 400 OK

on_close() takes 1 positional argument but 3 were given


(tensorflow) C:\Users\Raghav.Atal\Documents\Developer\external_code_repos\websocket-api\Applications\Examples\python>python market_price.py --host trep-dacs-main.corp.stonex.com --user MDHUB

Connecting to WebSocket ws://trep-dacs-main.corp.stonex.com:15000/WebSocket ...

Handshake status 400 OK

on_close() takes 1 positional argument but 3 were given


(tensorflow) C:\Users\Raghav.Atal\Documents\Developer\external_code_repos\websocket-api\Applications\Examples\python>python market_price.py --host trep-dacs-main.corp.stonex.com --user MDHUB

Connecting to WebSocket ws://trep-dacs-main.corp.stonex.com:15000/WebSocket ...

WebSocket successfully connected!

People who like this

0 Show 0
Comment
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

4 Replies

  • Sort: 
avatar image
REFINITIV
Best Answer
Answer by zoya faberov · Aug 17, 2021 at 09:07 PM

Hello @Raghav Atal ,

I would suggest to confirm, that your Python version is new, modules websocket and websocket-client are recent if not the latest, and to verify the same with the latest example code available from Refinitiv GitHub Websocket examples repository.

You may wish to also test the connection to the same RTDS host with Try It Out example, please find the details in Quick Start - Connecting to Refinitiv Real-Time Distribution System.

I completely agree with @nick.zincone.1 If you continue experiencing the connectivity issue, would next reach out to your market data/network group in charge of RTDS (formerly TREP).

Comment

People who like this

0 Show 0 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

avatar image
REFINITIV
Answer by nick.zincone · Aug 17, 2021 at 08:54 PM

Hi @Raghav Atal

There are a couple of things I would suggest you do. It appears the example code 'market_price.py' may have implemented an old signature for some of the callbacks. For example, it is complaining about the number of arguments passed to the on_close(). Within the example, it only defines one positional argument - I would suggest you update the example so the on_close() looks like this:

def on_close(ws, close_status_code, close_msg):
    print("### closed ###")

Update the code to print out the status code and msg arguments that are being passed in. This should at least provide some clue as to why it is failing to connect to your local market data system and also eliminate the error message:

on_close() takes 1 positional argument but 3 were given

Assuming it will provide any more meaningful information, I would reach out to your market data team to understand why it is rejecting your request - providing to them this information. At first glance, it doesn't appear the code is the issue but rather the server.

Comment

People who like this

0 Show 2 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

avatar image
Raghav Atal · Aug 18, 2021 at 11:01 AM 0
Share

Hello Nick,

I even tried with updated signature for on_close function and printed out the close_status_code and close_msg but both of them are set to None. The on_close error is now gone, but the problem of not connecting to the websocket still remains.


(tensorflow) C:\Users\Raghav.Atal\Documents\Developer\external_code_repos\websocket-api\Applications\Examples\python>python market_price.py --host trep-dacs-main.corp.stonex.com --user MDHUB

Connecting to WebSocket ws://trep-dacs-main.corp.stonex.com:15000/WebSocket ...

Handshake status 400 OK

Close_status_code: None

close_msg: None

WebSocket Closed

avatar image
REFINITIV
nick.zincone ♦♦ Raghav Atal · Aug 18, 2021 at 12:35 PM 0
Share
Hi @Raghav Atal

Given there are no additional details within the on_close that explain why the request is failing, I would suggest you reach out to your market data team as they can explain why they are rejecting the request.

avatar image
REFINITIV
Answer by umer.nalla · Aug 18, 2021 at 08:14 AM

Hi @Raghav Atal

I seem to recall that the error 'on_close() takes 1 positional argument but 3 were given ' occurs when the websocket library is installed - rather than websocket-client

Can you confirm you have done:

pip install websocket-client

Please the Websocket API QuickStart for further details


Comment

People who like this

0 Show 0 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

avatar image
REFINITIV
Answer by nick.zincone · Aug 18, 2021 at 12:41 PM

Hi @Raghav Atal

Can you confirm where you pulled that example (market_price.py) from? If it is not from here (https://github.com/Refinitiv/websocket-api/blob/master/Applications/Examples/python/market_price.py), can you try that version. Also, can you confirm the version of Python you are using? Confirm the WebSocket library? Also, can you try running the example without specifying any user name? I want to see how the example responds. Thanks.

Comment

People who like this

0 Show 0 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Watch this question

Add to watch list
Add to your watch list to receive emailed updates for this question. Too many emails? Change your settings >
11 People are following this question.

Related Questions

TRCC error Error:1002 ipcRead() failure. System errno: (0)

rrdump error

ADS Question

Opaque message size limitations

Swap rate MYRSN= mid price not available

  • Copyright
  • Cookie Policy
  • Privacy Statement
  • Terms of Use
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Alpha
  • App Studio
  • Block Chain
  • Bot Platform
  • Connected Risk APIs
  • DSS
  • Data Fusion
  • Data Model Discovery
  • Datastream
  • Eikon COM
  • Eikon Data APIs
  • Electronic Trading
    • Generic FIX
    • Local Bank Node API
    • Trading API
  • Elektron
    • EMA
    • ETA
    • WebSocket API
  • Intelligent Tagging
  • Legal One
  • Messenger Bot
  • Messenger Side by Side
  • ONESOURCE
    • Indirect Tax
  • Open Calais
  • Open PermID
    • Entity Search
  • Org ID
  • PAM
    • PAM - Logging
  • ProView
  • ProView Internal
  • Product Insight
  • Project Tracking
  • RDMS
  • Refinitiv Data Platform
    • Refinitiv Data Platform Libraries
  • Rose's Space
  • Screening
    • Qual-ID API
    • Screening Deployed
    • Screening Online
    • World-Check One
    • World-Check One Zero Footprint
  • Side by Side Integration API
  • TR Knowledge Graph
  • TREP APIs
    • CAT
    • DACS Station
    • Open DACS
    • RFA
    • UPA
  • TREP Infrastructure
  • TRKD
  • TRTH
  • Thomson One Smart
  • Transactions
    • REDI API
  • Velocity Analytics
  • Wealth Management Web Services
  • Workspace SDK
    • Element Framework
    • Grid
  • World-Check Data File
  • 中文论坛
  • Explore
  • Tags
  • Questions
  • Badges