Binary RPC in node.js - json

In general, supposing your server, written in Javascript in the node.js environment, is assembling a response to an end user from services provided by other servers, is there any reasonable alternative to having them all talk JSON?
RPC calls usually use XDR, which is binary, or JSON, which is ascii. There are handy libraries to take care of all the boring sockets stuff for you for these cases.
Node.js tools to use RPC are available for RPC in JSON, but is there any easy way to access RPC calls in binary formats such as XDR, ASN.1 PER, or Avro Apache from node.js. Or to do something similar?
I am not asking what is the best way, or what can be done, because anything can be done with enough hard work, but rather what ways have standards to avoid reinventing the wheel, and libraries to do as much of the work as possible.

avsc implements Avro's RPC specification, you can use it to expose "type-safe" services over any transport (e.g. HTTP, TCP, WebSockets). The quickstart guide goes through a simple example that should help you get started. (Disclaimer: I wrote it.)

Related

REST API or Java SDK, Which is preferable for monitoring Oracle Cloud Compute VM?

Which one makes process easier, minimum lines to code and easy to use.
The Java SDK will be easier, assuming you are used to coding in Java. With using the REST API directly, you have to managing the signing logic yourself, as well as be familiar with HTTP semantics like URI, path, query params, headers, body, etc. The Java SDK (and the other OCI SDKs) abstract that all away for you.

Are there any general purpose exception-handling frameworks for capturing and managing exceptions?

We have a system built on MarkLogic, Java / GlassFish. We need some kind of system that could capture thrown exceptions from any of those three subsystems, and then provide a nice web-based reporting interface where exceptions could be viewed, prioritized, marked done. We use JIRA.com in the cloud so if there was any way to integrate with that, it would be nice. Prefer open source or inexpensive.
I'm not sure whether a Java-based system would accomodate our MarkLogic errors, so I believe we need something that is language-agnostic.
Thanks.
If you are communicating with MarkLogic using a MarkLogic "HTTP appserver" (as opposed to XCC or WebDAV), then you can use the error handler configuration as a choke point for catching unhandled exceptions. I've never tried this, but, in theory, in the error handler, you could make an http request and send them anywhere you want.
See http://docs.marklogic.com/5.0doc/docapp.xqy#display.xqy?fname=http://pubs/5.0doc/xml/dev_guide/appserver-control.xml%2387072
If you are using XCC, then there are other places to put choke points in your Java code.
MarkLogic writes exceptions by default to the Data/Logs/ErrorLog.txt file. Application code within MarkLogic can use xdmp:log, or trace() to log messages to the same file. The file can be accessed quite easily through file-system if GlassFish is running on the same host., It can also be disclosed through an App Server within MarkLogic with some custom XQuery code.
GlassFish itself appears to be a Java EE platform. I expect it to do logging using something like Log4J. The logging messages in the ErrorLog and the Log4J log will likely not be formatted identically, but basic properties should be there, like date/time, and error message. Log4J logging can be set to write to a log file as well. You could consume it in a similar way as the ErrorLog.
I am not aware of any error reporting web-interface for such logging, but I believe JIRA provides an HTTP API, which can be used to push information into it.

application design: Scala + HTML5

I'd like to implement an application with Scala and HTML5. My idea was to create a "local" client-server architecture: Scala handles the calculations and generates HTML5 as a GUI.
To my mind there are two possibilities
Use a Java/Scala framework that allows embedded HTML5. SWT for example has a browser widget. JavaFX seems good, too.
Distribute the program with a server and run it in a browser on localhost.
It would probably be most convenient to require an internet connection and forget about the localhost. Unfortunately an offline mode is necessary.
Now I would like to know how to get this right:
The first option seems easier to implement but I wonder: How can I communicate with Javascript without the HTTP protocol ?
The second approach was just an idea. Have you ever done something like this ?
If you've got advice or know a good framework please go ahead.
UPDATE :
I've just had an interesting idea: Could I use nodejs to create something like a server-server architecture ?
Right now the communication between Scala and Coffescript seems like the most problematic part. I still wonder how I could initiate an update from the Scala side of the application. A HTTP Request is a nice way to exchange data. Sadly to my knowledge in "standard" Coffeescript there would be no event hook to listen to server-side HTTP messages.
I've thought about using nodejs to listen to the server-sent data. Is this a good idea ?
With regards to the second option, you may wish to investigate the Play! Framework or Lift. They automate a lot of the work required to make a web application in Scala, including handling AJAX requests.
Although I haven't tried packaging either for local use, there was an earlier Stack Exchange question about packaging Lift which might be relevant. It should be possible with Play! as well.

Amf PHP stateless?

Is amfPHP stateless? In case it is, is there a way to make it stateless. If there is, what would be the ideal way to implement security over amfphp ?
AmfPHP is stateless - each request is independent and unrelated to any previous request.
AMF is just a format like JSON or XML, it doesn't have any built-in security. You implement security like you do for any other web application - OAuth, SSL, etc.

WebSocket server list

I am looking to start a HTML5 WebSockets project and I was just wondering what you think the best back-end would be for that sort of thing? So far in my research I've stumbled across the following:
PHP Back-end (apparently a "Hack" and only compatible with Chrome and webkit nightlies)
Java Back-end (Seems well documented and cross-browser compatible)
Ruby Back-end (Don't know much about ruby, any opinions?)
JavaScript Library (Seems like it would be a nightmare, any opinions?)
Does anyone know of any other options or have an opinion on the above? My only requirements are ease of set-up and easy back end programmibility for bidirectional communication. I would essentially like to access a database through WebSockets and am looking for the easiest way to do this. Any feedback would be appreciated.
Ease of setup would have to be a hosted solution which uses WebSockets, HTTP Streaming or HTTP Long-Polling (one of which I work for). They're the easiest option because you don't need to spend time installing your solution, configuring it and working out how to use in when developing and in production.
If you are looking for a self hosted solution then it really depends on what technology you'd prefer to use and what the community for that technology is like.
Node.js and socket.io has a big community following at the moment so it wouldn't be a bad choice.
PHP - I'm afraid that PHP isn't really build with long-held persistent connections in mind. So, although there are options it's probably best to either use a hosted service or steer clear.
Ruby - check out Faye (also has node.js option), Juggernaut or Cramp
Java: As you say, jwebsocket or WaterSpout Server
Hope this helps.
I 'd recommend websocketd
http://websocketd.com/
It 's a thin layer you can wrap around any program that reads from stdin and writes to stdout and transform it to a websocket server.
So you can write in any language you like. Afterwards just
$ websocketd --port=8080 my-program
and you have your server.