-
Notifications
You must be signed in to change notification settings - Fork 84
Closed
Labels
Description
Hi
First of all excuse my noob-ness. I am not that good at C#.
I am trying to connect to an API but I am not getting it to work for days
var wampConnection = null;
var wampSession = null;
var wampUser = 'web';
var wampPassword = 'web';
function onChallenge(wampSession, method, extra) {
if (method == 'wampcra') {
return autobahn.auth_cra.sign(wampPassword, extra.challenge);
}
};
function connectionOpen(session, details) {
wampSession.call('f_all_miner_updates', ['0a7a6fade943f7b6b9e96b4d1516bfcc733b5158af18d1b43aeec7e45a238c02']).then(initialSessionUpdatesReceived);
};
function initialSessionUpdatesReceived(updates) {
//After handling the initial information, now subscribe to receive future updates.
wampSession.subscribe('miner_updates_0a7a6fade943f7b6b9e96b4d1516bfcc733b5158af18d1b43aeec7e45a238c02', onMinerUpdate);
};
function onMinerUpdate(update) {
//Handle live miner updates here.
};
wampConnection = new autobahn.Connection({
url : 'wss://live.prohashing.com:443/ws',
realm : 'mining',
authmethods: ['wampcra'],
authid: wampUser,
onchallenge: onChallenge
});
wampConnection.onopen = connectionOpen;
wampConnection.open();
**I am trying to mimick the same into C#**
class Program
{
static void Main(string[] args)
{
DefaultWampChannelFactory factory = new DefaultWampChannelFactory();
IWampClientAuthenticator authenticator = new WampCraClientAuthenticator(authenticationId: "web", secret: "web");
IWampChannel channel = factory.CreateJsonChannel("wss://live.prohashing.com:443/ws", "mining", authenticator);
IWampRealmProxy realmProxy = channel.RealmProxy;
channel.RealmProxy.Monitor.ConnectionEstablished +=
(sender, arg) =>
{
Console.WriteLine("connected session with ID " + arg.SessionId);
dynamic details = arg.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, arg) =>
{
dynamic details = arg.Details.OriginalValue.Deserialize<dynamic>();
Console.WriteLine("disconnected " + arg.Reason + " " + details.reason + details);
};
channel.Open().ConfigureAwait(false);
Console.ReadLine();
}
}
But I get a connection disconnected every time..