- aspect
- Archived posts: 6
- Joined: Apr 24, 2017
Unable to connect to WAMP from NodeJS
I have tried everything and am unable to connect to WAMP from NodeJs. Funny thing is that I see that site UI is connecting properly with same credentials and practically the same code. I tried autobahn and wampy, all with no results. As if the websocket doesn't respond.
Here is some test code:
Similar code clearly works in the browser, but I am at a loss at this point... any suggestions?
Here is some test code:
Code:
var autobahn = require('autobahn');
var wampConnection = null;
var wampUser = 'web';
var wampPassword = wampUser;
function onChallenge(wampSession, method, extra) {
console.log("challenge:",arguments);
if (method == 'wampcra') {
return autobahn.auth_cra.sign(wampPassword, extra.challenge);
}
};
function connectionOpen(session, details) {
console.log("connection open", arguments);
};
wampConnection = new autobahn.Connection({
url : 'wss://live.prohashing.com:443/ws',
realm : 'mining',
authmethods: ['wampcra'],
authid: wampUser,
onchallenge: onChallenge
});
wampConnection.onopen = connectionOpen;
wampConnection.open();