dxFeed / dxfeed-graal-net-api

For .NET developers, this library offers easy access to dxFeed market data. Built upon the GraalVM Native Image and our flagship dxFeed Java API, it provides a seamless experience for .NET-based applications
Mozilla Public License 2.0
11 stars 6 forks source link

Auth without port #53

Open gowthamnatarajan opened 6 months ago

gowthamnatarajan commented 6 months ago

My Broker has provided me with the link to connect and it does not have a port. Its something like wss://abc.dxfeed.com/realtime

How do I authenticate with a token?

stdcion commented 6 months ago

Hello @gowthamnatarajan

Most likely you're connecting to dxLink. For token-based authorization, use the following address format: "dxlink:wss://demo.dxfeed.com/dxlink-ws[login=dxlink:token]"

Here's an example of how to do it:

using System;
using DxFeed.Graal.Net;
using DxFeed.Graal.Net.Api;
using DxFeed.Graal.Net.Events.Market;

// Enable experimental feature.
SystemProperty.SetProperty("dxfeed.experimental.dxlink.enable", "true");
// Set scheme for dxLink.
SystemProperty.SetProperty("scheme", "ext:opt:sysprops,resource:dxlink.xml");

// For token-based authorization, use the following address format:
// "dxlink:wss://demo.dxfeed.com/dxlink-ws[login=dxlink:token]"
using var endpoint = DXEndpoint.Create().Connect("dxlink:wss://demo.dxfeed.com/dxlink-ws");
using var subscription = endpoint.GetFeed().CreateSubscription(typeof(Quote));
subscription.AddEventListener(events =>
{
    foreach (var e in events)
    {
        Console.WriteLine(e);
    }
});
subscription.AddSymbols("AAPL");
Console.ReadKey();