Status API returning exception message

Encounter a problem related to the pool or have a request for a feature? Post your issue here and we will help you out.
Forum rules
Welcome to the System Support forum! Encounter a problem related to the pool? Post your issue here and we will help you out.

Keep in mind that the forums are monitored by PROHASHING less closely than the official support channels, so if you have a pressing issue, please submit an official support ticket so that our Support Analyst can look into your issue in a timely manner.

We cannot answer financial questions related to your account on a public forum, so those questions should always be submitted through the orange Support button on prohashing.com/about.

For the full list of PROHASHING forums rules, please visit https://prohashing.com/help/prohashing- ... rms-forums.
Locked
kaptainkrayola
Posts: 7
Joined: Mon Apr 17, 2017 6:39 pm

Status API returning exception message

Post by kaptainkrayola » Wed May 10, 2017 3:41 pm

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.
User avatar
Steve Sokolowski
Posts: 4585
Joined: Wed Aug 27, 2014 3:27 pm
Location: State College, PA

Re: Status API returning exception message

Post by Steve Sokolowski » Wed May 10, 2017 6:07 pm

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.
kaptainkrayola
Posts: 7
Joined: Mon Apr 17, 2017 6:39 pm

Re: Status API returning exception message

Post by kaptainkrayola » Thu May 11, 2017 8:32 am

I'll work on the WAMP implementation - i see the docs.

thanks
kaptainkrayola
Posts: 7
Joined: Mon Apr 17, 2017 6:39 pm

Re: Status API returning exception message

Post by kaptainkrayola » Thu May 11, 2017 6:00 pm

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.
User avatar
Steve Sokolowski
Posts: 4585
Joined: Wed Aug 27, 2014 3:27 pm
Location: State College, PA

Re: Status API returning exception message

Post by Steve Sokolowski » Thu May 11, 2017 7:15 pm

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.
mjgraham
Posts: 16
Joined: Mon Oct 31, 2016 4:24 pm

Re: Status API returning exception message

Post by mjgraham » Thu May 11, 2017 8:26 pm

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.
kaptainkrayola
Posts: 7
Joined: Mon Apr 17, 2017 6:39 pm

Re: Status API returning exception message

Post by kaptainkrayola » Thu May 11, 2017 10:15 pm

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.
kaptainkrayola
Posts: 7
Joined: Mon Apr 17, 2017 6:39 pm

Re: Status API returning exception message

Post by kaptainkrayola » Thu May 11, 2017 10:19 pm

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.
User avatar
Steve Sokolowski
Posts: 4585
Joined: Wed Aug 27, 2014 3:27 pm
Location: State College, PA

Re: Status API returning exception message

Post by Steve Sokolowski » Sat May 13, 2017 8:18 am

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