I am trying to connect to the wamp API using WampSharp implementation, but i am getting "AuthenticationException: A call to SSPI failed, see inner exception." on the line
Code:
IDisposable disposable = RunAsync().Result;
this is the code i am using to connect. Is anybody able to help?
Code:
public static void Main(string[] args)
{
IDisposable disposable = RunAsync().Result;
Console.ReadLine();
disposable.Dispose();
}
private static async Task<IDisposable> RunAsync()
{
DefaultWampChannelFactory channelFactory = new DefaultWampChannelFactory();
IWampClientAuthenticator authenticator;
authenticator = new WampCraClientAuthenticator(authenticationId: "web", secret: "web");
const string serverAddress = "wss://live.prohashing.com:443/ws";
IWampChannel channel =
channelFactory.CreateJsonChannel(serverAddress, "mining", authenticator);
channel.RealmProxy.Monitor.ConnectionEstablished +=
(sender, args) =>
{
Console.WriteLine("connected session with ID " + args.SessionId);
dynamic details = args.WelcomeDetails.OriginalValue.Deserialize<dynamic>();
Console.WriteLine("authenticated using method '{0}' and provider '{1}'", details.authmethod,
details.authprovider);
Console.WriteLine("authenticated with authid '{0}' and authrole '{1}'", details.authid,
details.authrole);
};
channel.RealmProxy.Monitor.ConnectionBroken += (sender, args) =>
{
dynamic details = args.Details.OriginalValue.Deserialize<dynamic>();
Console.WriteLine("disconnected " + args.Reason + " " + details.reason + details);
};
IWampRealmProxy realmProxy = channel.RealmProxy;
await channel.Open().ConfigureAwait(false);
IWampSubject topic =
realmProxy.Services.GetSubject("profitability_updates");
IDisposable disposable =
topic.Subscribe(OnTopic2);
return disposable;
}
private static void OnTopic2(IWampSerializedEvent serializedEvent)
{
int[] arguments =
serializedEvent.Arguments.Select(argument => argument.Deserialize<int>())
.ToArray();
string c =
serializedEvent.ArgumentsKeywords["c"].Deserialize<string>();
ComplexContract d =
serializedEvent.ArgumentsKeywords["d"].Deserialize<ComplexContract>();
var deserializedArguments =
new
{
arguments,
argumentsKeywords = new
{
c,
d
}
};
Console.WriteLine("Got event: args: [{0}], kwargs: {{ {1} }}",
string.Join(", ", deserializedArguments.arguments),
deserializedArguments.argumentsKeywords);
}
public class ComplexContract
{
[JsonProperty("counter")]
public int Counter { get; set; }
[JsonProperty("foo")]
public int[] Foo { get; set; }
public override string ToString()
{
return $"counter: {Counter}, foo: [{string.Join(", ", Foo)}]";
}
}
}
}