WebSocket API - Need help on running "MarketPriceEdpGwServiceDiscoveryExample" with WebSocketShar...

...p 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


image

Best Answer

  • nick.zincone
    nick.zincone admin
    Answer ✓

    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"
    }"


Answers