WAMP API - "Connection is not a constructor"

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
Klexicon
Posts: 6
Joined: Sun May 21, 2017 9:54 pm

WAMP API - "Connection is not a constructor"

Post by Klexicon » Wed May 24, 2017 10:51 pm

Hello,

I've been beating my head against a wall with this for a few hours now, so I figured I'd come see if anyone could help me solve this issue. I'm trying to set up a WAMP connection in JS. I combined the code from the API section of the help page here with the "require" code at https://github.com/crossbario/autobahn- ... started.md.

Currently the console will log "Ok, Autobahn loaded" and the version number, but then throws an error when I attempt to open the connection. It states that "autobahn.Connection is not a constructor." As far as I can tell from googling, my code should be correct.

Note that I am running this code inside <script> tags in an HTML document and seeing the error in the developer console. My source repository is https://github.com/crossbario/autobahn-js-built. Any assistance is greatly appreciated.

Code: Select all

		require.config({
			baseUrl: ".",
			paths: {
				"autobahn": "\\autobahnJS\\autobahn.min",
				"when": "https://cdnjs.cloudflare.com/ajax/libs/when/2.7.1/when"
			},
			shim: {
				"autobahn": {
					deps: ["when"]
				}
			}
		});
		require(["autobahn"], function(autobahn) {
			console.log("Ok, Autobahn loaded", autobahn.version);
		});
		
		
		var autobahn = require(['autobahn']);
		var wampSession = null;
		var wampUser = 'web';
		var wampPassword = 'web';
		
		var connection = new autobahn.Connection({
			url : 'wss://live.prohashing.com:443/ws',
			realm : 'mining',
			authmethods: ['wampcra'],
			authid: wampUser,
			onchallenge: onChallenge
		});
		
		connection.onopen = connectionOpen;
		connection.open();
		
		function onChallenge(wampSession, method, extra) {
			if (method == 'wampcra') {
				return autobahn.auth_cra.sign(wampPassword, extra.challenge);
			}
		};
		
		function connectionOpen(session, details) {
			wampSession.subscribe('found_block_updates', onBlockUpdate);
			wampSession.call('f_all_miner_updates', ['...api...]).then(initialSessionUpdatesReceived);
		};
User avatar
Steve Sokolowski
Posts: 4585
Joined: Wed Aug 27, 2014 3:27 pm
Location: State College, PA

Re: WAMP API - "Connection is not a constructor"

Post by Steve Sokolowski » Mon May 29, 2017 8:58 am

Klexicon wrote:Hello,

I've been beating my head against a wall with this for a few hours now, so I figured I'd come see if anyone could help me solve this issue. I'm trying to set up a WAMP connection in JS. I combined the code from the API section of the help page here with the "require" code at https://github.com/crossbario/autobahn- ... started.md.

Currently the console will log "Ok, Autobahn loaded" and the version number, but then throws an error when I attempt to open the connection. It states that "autobahn.Connection is not a constructor." As far as I can tell from googling, my code should be correct.

Note that I am running this code inside <script> tags in an HTML document and seeing the error in the developer console. My source repository is https://github.com/crossbario/autobahn-js-built. Any assistance is greatly appreciated.

Code: Select all

		require.config({
			baseUrl: ".",
			paths: {
				"autobahn": "\\autobahnJS\\autobahn.min",
				"when": "https://cdnjs.cloudflare.com/ajax/libs/when/2.7.1/when"
			},
			shim: {
				"autobahn": {
					deps: ["when"]
				}
			}
		});
		require(["autobahn"], function(autobahn) {
			console.log("Ok, Autobahn loaded", autobahn.version);
		});
		
		
		var autobahn = require(['autobahn']);
		var wampSession = null;
		var wampUser = 'web';
		var wampPassword = 'web';
		
		var connection = new autobahn.Connection({
			url : 'wss://live.prohashing.com:443/ws',
			realm : 'mining',
			authmethods: ['wampcra'],
			authid: wampUser,
			onchallenge: onChallenge
		});
		
		connection.onopen = connectionOpen;
		connection.open();
		
		function onChallenge(wampSession, method, extra) {
			if (method == 'wampcra') {
				return autobahn.auth_cra.sign(wampPassword, extra.challenge);
			}
		};
		
		function connectionOpen(session, details) {
			wampSession.subscribe('found_block_updates', onBlockUpdate);
			wampSession.call('f_all_miner_updates', ['...api...]).then(initialSessionUpdatesReceived);
		};
Try contacting JoeTheMiner at memberlist.php?mode=viewprofile&u=1969. While I have only ever implemented our API on our own website (and therefore have little knowledge of Node,) Joe successfully used Node to implement it and maybe he can help you out.
Locked