javascript binding in a browser
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 titleAn 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
Re: javascript binding in a browser
Hi again Ernie, There's no real reason why it shouldn't work in a browser except that I haven't tried it in a while, it tends to be easier to try things out using node.js and doing some more browser tests was on my TODO list :-) The error Uncaught TypeError: Cannot read property 'fa' of null is less than helpful :-) that's 'cause it has been minified with closure. I doubt that you are doing anything especially wrong it'll just be something stupid I've done. If you look in the CMake and set closure 0 in this bit: LINK_FLAGS -s \EXPORT_NAME='proton'\ -s \WEBSOCKET_SUBPROTOCOL='AMQPWSB10'\ -O2 --closure 1 --memory-init-file 0 and recompile you'll get a more useful error but TBH if you can bear with me I'll try to take a look as it tomorrow, I can't do much this evening 'cause I've been putting up a fence and I'm knackered :-) I'll give you a ping when I've sorted it . 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 titleAn 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
[jira] [Created] (PROTON-657) OSX: build proton with homebrew openssl
Bozo Dragojevic created PROTON-657: -- Summary: OSX: build proton with homebrew openssl Key: PROTON-657 URL: https://issues.apache.org/jira/browse/PROTON-657 Project: Qpid Proton Issue Type: Improvement Components: proton-c Affects Versions: 0.7 Environment: OSX 10.9.4 Reporter: Bozo Dragojevic System supplied openssl deprecates practically all methods used by proton. Compile against openssl from homebrew which requires additional include and link directory. -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Updated] (PROTON-657) OSX: build proton with homebrew openssl
[ https://issues.apache.org/jira/browse/PROTON-657?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Bozo Dragojevic updated PROTON-657: --- Attachment: 0001-PROTON-657-OSX-build-proton-with-homebrew-openssl.patch homebrew openssl is keg-only and to make it work with pkg-config one has to do something like: $ ln -s /usr/local/Cellar/openssl/1.0.1h/lib/pkgconfig/* /usr/local/lib/pkgconfig/ OSX: build proton with homebrew openssl --- Key: PROTON-657 URL: https://issues.apache.org/jira/browse/PROTON-657 Project: Qpid Proton Issue Type: Improvement Components: proton-c Affects Versions: 0.7 Environment: OSX 10.9.4 Reporter: Bozo Dragojevic Attachments: 0001-PROTON-657-OSX-build-proton-with-homebrew-openssl.patch System supplied openssl deprecates practically all methods used by proton. Compile against openssl from homebrew which requires additional include and link directory. -- This message was sent by Atlassian JIRA (v6.2#6252)