Re my last mail,
I meant to say using the proton.js is fine BTW, the makefile actually builds it into fadams-javascript-binding/bld/proton-c/bindings/javascript which is what you'd normally get with CMake but then copies it to the node_modules directory 'cause that's generally more useful. For a real browser based application you'd generally take that file and serve it from your Web App, but as it's WebSocket based you don't actually need to serve it to be able to use it, you can run from the filesystem as you've discovered.

I also forgot to say that I don't really understand the bit:

"

When I browserify the proton.js into qpid-proton-browser.js and load that file 
instead, I get the following when the page loads:
Uncaught TypeError: Cannot read property 'replace' of undefined
proton is undefined
Uncaught ReferenceError: proton is not defined

The Uncaught TypeError is due to a referece to "process.argv[1]". If I manually edit the 
qpid-proton-browser.js file to define all the process properties that it wants, I still get the 
"proton is undefined" error.

"

What do you mean by "When I browserify the proton.js into qpid-proton-browser.js "? I just copied proton.js to qpid-proton-browser.js
in fadams-javascript-binding/node_modules/qpid-proton/lib

and changed the script tag in the HTML to point to that and it still works for me and it gives the same error as proton.js when I remove the "tracker =" bit in front of messenger.put(message)


So I'm not really sure what you did that gave you the different error.

as I say using the proton.js is fine, but I'm curious as to what you actually did?

Frase



On 30/08/14 16:25, Ernest Allen wrote:
Hi Fraser,
I'm trying to run the proton javascript bindings from within a browser. I'm 
getting various errors depending on the way I'm doing it and I was hoping you 
could shed some light on the correct approach.
I have node recv.js running in a separate window.

The first way I tried was just including proton.js directly. When I load the 
page the console shows the following for the HTML listed below:
pre-main prep time: 6 ms
proton is [object Object]
before put
Uncaught TypeError: Cannot read property 'fa' of null
Uncaught TypeError: Cannot read property 'fa' of null

Here is the HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml";>

<head>
        <title>An XHTML 1.0 Strict standard template</title>
        <meta http-equiv="content-type"
                content="text/html;charset=utf-8" />

<script type="text/javascript" 
src="../../../node_modules/qpid-proton/lib/proton.js"></script>

<script type="text/javascript">
//<![CDATA[

console.log("proton is " + window.proton);
var address = "amqp://0.0.0.0";
var subject = "BrowserMessage";
var msgtext = "Hello From Browser!";
var tracker = null;
var running = true;

var message = new proton.Message();
var messenger = new proton.Messenger();

var pumpData = function() {
     var status = messenger.status(tracker);
     if (status != proton.Status.PENDING) {
         if (running) {
             messenger.stop();
             running = false;
         }
     }

     if (messenger.isStopped()) {
         message.free();
         messenger.free();
     }
};

messenger.on('error', function(error) {console.log("this is the error" + 
error);});
messenger.on('work', pumpData);
messenger.setOutgoingWindow(1024);
messenger.start();

message.setAddress(address);
message.setSubject(subject);
message.body = msgtext;

console.log("before put");
messenger.put(message);

        
//]]>
</script>
</head>

<body>
</body>

</html>

The output in the window running node recv.js is:
[0x535398]:ERROR[-2] AMQP header mismatch: '' (connection aborted)

CONNECTION ERROR connection aborted (remote)



When I browserify the proton.js into qpid-proton-browser.js and load that file 
instead, I get the following when the page loads:
Uncaught TypeError: Cannot read property 'replace' of undefined
proton is undefined
Uncaught ReferenceError: proton is not defined

The Uncaught TypeError is due to a referece to "process.argv[1]". If I manually edit the 
qpid-proton-browser.js file to define all the process properties that it wants, I still get the 
"proton is undefined" error.

Do you know what I'm doing wrong?

Thanks,
-Ernie

Reply via email to