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

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
44 6 10 12

WebSocket API - Need help on running "MarketPriceEdpGwServiceDiscoveryExample" with WebSocketSharp dll (Open source)

Hi Team,

Need your assistance while running the "MarketPriceEdpGwServiceDiscoveryExample" with WebSocketSharp dll (Open source).

Using the WebSocketSharp dll (Open source), I am able to do the authentication (the first step) but not able to make a WebSocket connection and the Ping result is coming as false and not able to connect to the server.

As per my understanding that we should be able to use the WebSocketSharp dll (Open source) to connect to WebSocket server in "MarketPriceEdpGwServiceDiscoveryExample" example.

Note: I am able to connect to the WebSocket Server without any issues when I use the inbuild WebScoket functionality of .NET Framework as mentioned in the example.

Also, I have all the required details to connect to a WebScoket server.

Could you please let me know your thoughts.

Thanks

Pradeep B


treprdp-apiwebsocketsrrto
1612197603352.png (86.7 KiB)
icon clock
10 |1500

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

Upvote
Accepted
9.7k 49 38 60

Hi @pradeep.badoni,

These are the steps you need to take:

1. Connect into the server:

WebSocket = new WebSocket(_uri.ToString(), "tr_json2");
WebSocket.SslConfiguration.EnabledSslProtocols = System.Security.Authentication.SslProtocols.Tls12;
...
WebSocket.connect();

*Note* Don't set cookies.


2. Login to the server

{
  "ID": 1,
  "Domain": "Login",
  "Key": {
    "Name": <streaming ID>,  eg: "john.doe"
    "Elements": {
      "ApplicationId": "256",
      "AppKey": "256",
      "Position": "192.168.0.35",
      "AuthenticationToken": "hRkY1Tmg4LTM4...d6bMP_VpwPRw"
    },
    "NameType": "AuthnToken"
  }
}"

*Note* - as per OAuth requirements, you will need to re-authenticate with the server using a new authentication token


3. Send your messages

Open your subscription:

{
  "Key": {
    "Name": "EUR="
  },
  "ID": 2
}"


Close your subscription:

{
  "ID": 2,
  "Type": "Close"
}"


icon clock
10 |1500

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

Upvotes
9.7k 49 38 60

Hi @pradeep.badoni,

You will need to enable SSL protocols, for example:

WebSocket = new WebSocket(_uri.ToString(), "tr_json2");
WebSocket.SslConfiguration.EnabledSslProtocols = System.Security.Authentication.SslProtocols.Tls12;

If you are developing in .Net, you also have the option of using the RDP Libraries. There is a .Net community-based implementation available.

icon clock
10 |1500

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

@nick.zincone.1

Still no luck. The ping is still showing false.

Let me know if I am missing anything here.

1612199102417.png (73.8 KiB)
Upvotes
9.7k 49 38 60

Hi @pradeep.badoni,

Sorry, forgot to mention that you don't need to utilize the underlying WebSocket ping functionality. The protocol requires a specific PING request to be sent. When you review the "MarketPriceEdpGwServiceDiscoveryExample" example, you can see that 'Ping' messages are sent from the server and that you will need to respond with a 'Pong', i.e.

case "Ping":
    SendMessage("{\"Type\":\"Pong\"}");
    break;
default:
    break;
icon clock
10 |1500

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

Hi @nick.zincone.1

Thanks for the above suggestion, after removing the explicit Ping, i am able to connect the server, but get the below exception.

Note: i am not sending any log-in message we per the below comments in the examples:

/* Don't login -- the authentication token should do that for us. Just wait for the login refresh. */

let me know your thoughts.

1612226884478.png (143.3 KiB)

WebSocketSharp-02022021102019.txt

Hi @nick.zincone.1,

I did enable the trace log and got the more detail on the error message detail (see attached).

Could you please help to find the issue. I am stuck here and not able to move forward.

Thanks

Pradeep B


Upvotes
38.1k 71 35 53

@pradeep.badoni

Please remove WebSocket.SetCookie from the code.

From my test, there is no need to set cookies in the WebSocket connection.

icon clock
10 |1500

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

Upvotes
44 6 10 12

Hi @nick.zincone.1

Thanks for the above detail. I am successfully able to connect to the server and get the market data.

Need some more help.

I am building my new application using .NET Framework 3.5 and WebSocket-Sharp.

And while doing authentication, I am getting the below error message:

"Authentication failed because the remote party has closed the transport stream"

I am pretty much sure that this is related to "ServicePointManager.SecurityProtocol" and currently set like:

ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls

Could you please let me know what should be appropriate value for "ServicePointManager.SecurityProtocol".

Also, let me know if the above is not correct.

icon clock
10 |1500

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

Upvotes
44 6 10 12

Hi @nick.zincone.1

I got the answer for it and the issue got fix by adding the below code line:

ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;

icon clock
10 |1500

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

Upvotes
44 6 10 12

Hi @nick.zincone.1

Need help with new error message.

I am getting this error in the DicoveryServices() method. I didn't faced with issue in the past.



icon clock
10 |1500

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

Hi @pradeep.badoni,

Could you possibly ask this question on a new thread? It helps drive the community by keeping questions separate and to help others if they run into the same issues.

thanks.

Hi @nick.zincone.1

Noted Thanks...

Click below to post an Idea Post Idea