For a deeper look into our Elektron API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
1 0 0 2

Problem Login to WebSocket API

Using a Windows C# test program, we are getting reliable Authentication responses from api.ppe.refinitiv.com.

We are now trying to login to the WebSocket API at ws://api.ppe.refinitiv.com:15000/WebSocket.using the WebSocketSharp.WebSocket (1.0.3-rc11) which is connecting and appears to be sending:

GET /WebSocket HTTP/1.1

User-Agent: websocket-sharp/1.0

Host: api.ppe.refinitiv.com:15000

Upgrade: websocket

Connection: Upgrade

Sec-WebSocket-Key: xxxxxxx

Sec-WebSocket-Protocol: tr_json2

Sec-WebSocket-Version: 13

Cookie: ApplicationId=256; AuthenticationToken=xxxxxxx

Note the AuthenticationToken is truncated.

After a few seconds of connect, the WebSocket is abruptly closed with the error code 1006 and reason '"An exception has occurred while connecting."'.

We have also set the Authentication Token, Position and Application Id cookies that are to be sent during the login process. But the documentation and example code we have is not consistent as to the naming convention of these cookies:

AuthToken or AuthenticationToken or AuthnToken

AuthPosition or Position

applicationId or ApplicationId

Furthermore, we are not getting any of the events: OnOpen, OnError.

Can you indicate where we may be going wrong?

Maybe there is a more recent document than “WebsocketAPI_ProtocolSpecification.pdf” v1.4 of Oct 2020?

Many thanks in advance







websocketsc#error-login
icon clock
10 |1500

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

<AHS>

the original code with token and key

GET /WebSocket HTTP/1.1

User-Agent: websocket-sharp/1.0

Host: api.ppe.refinitiv.com:15000

Upgrade: websocket

Connection: Upgrade

Sec-WebSocket-Key: fhezXPQ7HAD+UXcQLY7K9w==

Sec-WebSocket-Protocol: tr_json2

Sec-WebSocket-Version: 13

Cookie: ApplicationId=256; AuthenticationToken=eyJ0eXAiOiJhdCtqd3QiLCJhbGciOiJSUzI1NiIsImtpZCI……..0Y1diMUtEdGhaaHF2eENNQnBBb1kifQ.eyJkYXRhIjoie1wiY2lwa……..tSkFZY2...|

Note the AuthenticationToken is truncated.

After a few seconds of connect, the WebSocket is abruptly closed with the error code 1006 and reason '"An exception has occurred while connecting."'.

@tony10

Hi,

Thank you for your participation in the forum.

Are any of the replies below satisfactory in resolving your query?

If yes please click the 'Accept' text next to the most appropriate reply. This will guide all community members who have a similar question.

Otherwise please post again offering further insight into your question.

Thanks,

AHS

Please be informed that a reply has been verified as correct in answering the question, and has been marked as such.

Thanks,
AHS

Upvote
Accepted
22k 58 14 21

Hi @tony10,

Can you please try this .NET example and see if it works for you? In your example, you are sending the authentication token along with the connection-upgrade request. Server is expecting a login request message on the websocket instead and maybe why it closes the connection.

Either way, please use one of the samples to understand the workings. Thanks.

icon clock
10 |1500

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

Upvotes
24.6k 54 17 14

Hello @tony10

Besides the example suggested by my colleague, you can find WebSocket Real-Time streaming workflow tutorials from the following resources:

The code example in the tutorial pages are written in Python, but the workflow concept is the same with C# or other languages.


icon clock
10 |1500

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

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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