Page 1 of 1

Status API returning exception message

Posted: Wed May 10, 2017 3:41 pm
by kaptainkrayola
When I query the live stats api https://prohashing.com/api/status?key=XXX I get back the message : { message: 'An unexpected exception occurred. The issue has been logged.' }. The error only occurs if i use the key for an account with a lot of miners though. If i use they key from an account with no miners it returns fine.

Re: Status API returning exception message

Posted: Wed May 10, 2017 6:07 pm
by Steve Sokolowski
kaptainkrayola wrote:When I query the live stats api https://prohashing.com/api/status?key=XXX I get back the message : { message: 'An unexpected exception occurred. The issue has been logged.' }. The error only occurs if i use the key for an account with a lot of miners though. If i use they key from an account with no miners it returns fine.
The REST API is now unsupported. We asked in the forums if there would be opposition to reassigning resources to support a new live WAMP API, which can provide instant updates with less bandwidth.

Check out the WAMP API in the documentation. If you can implement that, it will provide you with much more data that changes within milliseconds, instead of being averaged over 90 seconds.

Re: Status API returning exception message

Posted: Thu May 11, 2017 8:32 am
by kaptainkrayola
I'll work on the WAMP implementation - i see the docs.

thanks

Re: Status API returning exception message

Posted: Thu May 11, 2017 6:00 pm
by kaptainkrayola
I was able to get node.js to work with your api but there are two issues

1. Node.js does not like your SSL cert for some reason so you have to add

Code: Select all

process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
to your code otherwise node simply will not talk to your service

2. Your example code has an error at the top where you define

Code: Select all

var wampConnection = null;
var wampUser = 'web';
var wampPassword = 'web';
you also need

Code: Select all

var wampSession = null 
if you don't define "wampSession" then down in the initialSessionUpdatesReceived function it won't be defined and you won't get your subscription hooked up. The reference inside of connectionOpen isn't valid either. I see that session is passed to connectionOpen but i'm not sure if it's the same session data or not. Adding the wampSession definition above at the top fixes the error and I get miner updates now.

Re: Status API returning exception message

Posted: Thu May 11, 2017 7:15 pm
by Steve Sokolowski
kaptainkrayola wrote:I was able to get node.js to work with your api but there are two issues

1. Node.js does not like your SSL cert for some reason so you have to add

Code: Select all

process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
to your code otherwise node simply will not talk to your service

2. Your example code has an error at the top where you define

Code: Select all

var wampConnection = null;
var wampUser = 'web';
var wampPassword = 'web';
you also need

Code: Select all

var wampSession = null 
if you don't define "wampSession" then down in the initialSessionUpdatesReceived function it won't be defined and you won't get your subscription hooked up. The reference inside of connectionOpen isn't valid either. I see that session is passed to connectionOpen but i'm not sure if it's the same session data or not. Adding the wampSession definition above at the top fixes the error and I get miner updates now.
Wow, thanks! That explains why people were having trouble connecting.

But for some reason this code still works on the web version, so I guess that the SSL certificate issue is only a node.js issue? I'm not familiar with node.js, so I'm glad someone was able to help me out.

I'll check in your changes to the website code, and they should go out this weekend. I told Chris to tip you $5 for your hard work by crediting your account, since you did a great service to the community and to us.

Re: Status API returning exception message

Posted: Thu May 11, 2017 8:26 pm
by mjgraham
Just to add a bit I never could get the examples to work either but finally after looking at another example for poloniex I got this going, just to get the data and dump it to a JSON string so I can work on it elsewhere .

Code: Select all

process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = '0';

var autobahn = require('autobahn');
var wsuri = "wss://live.prohashing.com:443/ws";
var wampUser = 'web';
var wampPassword = wampUser;

var connection = new autobahn.Connection({
  url: wsuri,
  realm: "mining",
  authmethods: ['wampcra'],
  authid: wampUser,
  onchallenge: onChallenge
});

function onChallenge(wampSession, method, extra) {
        if (method == 'wampcra') {
                return autobahn.auth_cra.sign(wampPassword, extra.challenge);
        }
};

connection.onopen = function (session) {
        session.subscribe('profitability_updates', onProfitabilityUpdate);
        session.call('f_all_miner_updates', ['api_key']).then(initialSessionUpdatesReceived);
        session.subscribe('miner_updates_api_key', onMinerUpdate);
}
        function initialSessionUpdatesReceived(args,kwargs) {
                console.log(JSON.stringify(args));
        };


        function onProfitabilityUpdate(args,kwargs) {
                console.log(JSON.stringify(args[0]));
        };

        function onMinerUpdate(args,kwargs) {
                console.log(JSON.stringify(args[0]));
        };
connection.onclose = function () {
  console.log("Websocket connection closed");
}

connection.open();
of course replace apt_key with your key and you should get profit updates and miner updates and whatever else you can do to make it awesome.

Re: Status API returning exception message

Posted: Thu May 11, 2017 10:15 pm
by kaptainkrayola
FYI - i published a wrapper for the whole thing on github and npm

https://www.npmjs.com/package/prohashing
https://github.com/KaptainKrayola/prohashing

Hopefully this will make it really easy for people to implement in the future.

Re: Status API returning exception message

Posted: Thu May 11, 2017 10:19 pm
by kaptainkrayola
Steve Sokolowski wrote:
kaptainkrayola wrote:I was able to get node.js to work with your api but there are two issues

1. Node.js does not like your SSL cert for some reason so you have to add

Code: Select all

process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
to your code otherwise node simply will not talk to your service

2. Your example code has an error at the top where you define

Code: Select all

var wampConnection = null;
var wampUser = 'web';
var wampPassword = 'web';
you also need

Code: Select all

var wampSession = null 
if you don't define "wampSession" then down in the initialSessionUpdatesReceived function it won't be defined and you won't get your subscription hooked up. The reference inside of connectionOpen isn't valid either. I see that session is passed to connectionOpen but i'm not sure if it's the same session data or not. Adding the wampSession definition above at the top fixes the error and I get miner updates now.
Wow, thanks! That explains why people were having trouble connecting.

But for some reason this code still works on the web version, so I guess that the SSL certificate issue is only a node.js issue? I'm not familiar with node.js, so I'm glad someone was able to help me out.

I'll check in your changes to the website code, and they should go out this weekend. I told Chris to tip you $5 for your hard work by crediting your account, since you did a great service to the community and to us.

I'm guessing that since your cert works fine in the browsers it's a non-issue for client side implementations. NodeJS is likely just validating the cert a different way or is missing an intermediary in its particular cert store. The really fun part is that autobahnJS suppresses ALL unhandled exceptions so you didn't get an error trying to connect, your app just sat there doing nothing.

Thanks for the Tip, much appreciated. I really like the WS connection as well since push is always better than polling.

Re: Status API returning exception message

Posted: Sat May 13, 2017 8:18 am
by Steve Sokolowski
kaptainkrayola wrote:
Steve Sokolowski wrote:
kaptainkrayola wrote:I was able to get node.js to work with your api but there are two issues

1. Node.js does not like your SSL cert for some reason so you have to add

Code: Select all

process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
to your code otherwise node simply will not talk to your service

2. Your example code has an error at the top where you define

Code: Select all

var wampConnection = null;
var wampUser = 'web';
var wampPassword = 'web';
you also need

Code: Select all

var wampSession = null 
if you don't define "wampSession" then down in the initialSessionUpdatesReceived function it won't be defined and you won't get your subscription hooked up. The reference inside of connectionOpen isn't valid either. I see that session is passed to connectionOpen but i'm not sure if it's the same session data or not. Adding the wampSession definition above at the top fixes the error and I get miner updates now.
Wow, thanks! That explains why people were having trouble connecting.

But for some reason this code still works on the web version, so I guess that the SSL certificate issue is only a node.js issue? I'm not familiar with node.js, so I'm glad someone was able to help me out.

I'll check in your changes to the website code, and they should go out this weekend. I told Chris to tip you $5 for your hard work by crediting your account, since you did a great service to the community and to us.

I'm guessing that since your cert works fine in the browsers it's a non-issue for client side implementations. NodeJS is likely just validating the cert a different way or is missing an intermediary in its particular cert store. The really fun part is that autobahnJS suppresses ALL unhandled exceptions so you didn't get an error trying to connect, your app just sat there doing nothing.

Thanks for the Tip, much appreciated. I really like the WS connection as well since push is always better than polling.
Your code is now featured in the documentation. In a future release next weekend, I'll add links to your packages. Your tip has also been paid.