I want to create a Meteor application that interacts with the user and at the same time receives market data from multiple TCP sockets. I intend to channel the market data (from various TCP sockets) into one collection.
I had been looking around but i do not see a net.createServer method for Meteor. Can anyone give any pointers for me to start?
Thanks in advance!
Meteor has a packaging system that allows you to use node modules. So I would look at node modules to find the server functionality you want to add. The node core module http might be a good start.
You can also just search the NPM registry for a module with functionality that fits your needs better. Then just include it in you Meteor app through the packaging system. I have included the NPM pubsubhubbub in an rss aggregator that listens for pings and fills client collections so the package I used might be an example to follow.
Listening for data arriving on other ports or other domains will not work for a deployment on meteor.com so I think what you are describing will also require you to host the app.
Related
I am currently looking at possible development models for a device that will be in a clients home. I need the device to run a local copy of Meteor while also being able to get and insert information from a central server in a secure/reactive way.
All sensitive information has not been included in this image
I am required to make a local server as I need to run shell commands on the device. While the device could make HTTP webhook calls, it would be slow due to packet travel time and does not meet requirements.
I know that the local server could connect to the Central Server mongodb which would be ideal, however as this local server is physically located in a clients house, this means that the mongodb password would be exposed (big security problem). Also I would be unable to control what information is sent to the local server. I was unable to find a way to subscribe to an external server, which would be a great solution.
Another way could be that the local server simply use HTTP requests, however another requirement is that Audit requests appear almost as soon as they are issued which is ideal for a reactive mongodb item. A heartbeat wouldn't really fit due to the data/processing overheads and slowness.
The summary the question is: How to make a device to run a local copy of Meteor while also being able to get and insert information from a central server in a secure/reactive way.
Well in the end, I found that you can use cross-server and even CORS connections with https://docs.meteor.com/api/connections.html
So now any aspiring developer can use the DDP framework.
I have an application that I inherited that listens on port 7001 for UDP broadcasts from our in-house test equipment, and I recently updated another application that needs to do the same thing. Both applications must be able to coexist on the same computer.
Currently, when my recently updated application attempts to bind to the port to listen for UDP broadcasts and fails, it simply reports that the port is not available and suggests that the inherited application is probably running. How can I get my application to detect what application is actually listening on that port? I've done a Google search and have even searched this site, but so far I have been unable to find anything except to use Task Manager, TCPView, or netstat at the command line.
I would prefer a technique that either uses the Windows API or a Windows system COM component, since both applications are written in Visual Basic 6.0. (I know, I know, but I must maintain these applications since they are mission critical.) However, a .NET solution would would also be useful in case I need it in my new development efforts.
Use:
netstat -n -o
That will show the process ID and from there you can either look in the Task Manager's process viewer, go to menu View → Columns... and check the Process ID (PID). Then you can see the name of the process listening on that port.
Of course, you're wanting a programmatic way of accomplishing this and the GetTCPTable2 API is best as was already suggested. In fact, if you look at the IAT (Import Address Table) for netstat.exe, it actually uses that API to get that information.
There is a way to communicate directly with a command window and get its output using pipes and it would work fine, but the ideal way is to simply use the same API netstat uses.
So I've tested this particular example on my local machine:
http://bjorngylling.com/2011-04-13/postgres-listen-notify-with-node-js.html
It worked! So now when I update a specific table, and am running my node.js file(from the tutorial) -I get an instant notification on my Terminal(mac)!! cool!
But how do I implement this onto a client's browser??
First of all, in the node.js script you'll notice that I have to connect to the database with my username and password:
pgConnectionString = "postgres://username:pswd#localhost/db";
I obviously can't have that floating around in the .js file the user's browser downloaded.
Plus I don't even know what scripts I'd have to include in the <head>. I can't find anything anywhere on how this is used in the real world.... All I see are neat little examples you can use in your command line.
Any advice, or guidance in the right direction would be awesome! Thanks.
You can't.
Node.js runs directly on your server, speaking directly to the native libraries on that machine. I'm not sure exactly what the postgres driver you are using does, but either it speaks to the postgres libraries OR it speaks directly with sockets on the local or a remote database server.
Neither of these methods can be used directly from a browser environment (it can't speak directly to the native libraries and it can't speak "raw" sockets).
What you can do is to have the web client speak to your own server process on a server (running node.js or similar), which would then speak to the database on behalf of the client.
Assuming you also need to database server to be able to initiate notifications to the client, you would need to use a bi-directional communication module like socket.io or similar.
You can do: combine your JS running on node.js which accesses Postgres listening for events with a node.js based WebSocket server, implement PubSub and push out to HTML5 browsers .. WebSocket capable ones.
Another option: use a generic WebSocket to TCP bridge like https://github.com/kanaka/websockify and implement the Postgres client protocol in JS to run in browser. That is doable, but probably not easy / for the faint hearted.
I am working with the BlueZ libraries for managing the bluetooth stack under linux. I am trying to open a socket that should connect with a specific service whose UUID is known. I have successfully tried to open sockets between a server and a client following the examples here:
http://people.csail.mit.edu/albert/bluez-intro/c404.html
where it is also described how to explore services in a remote host; however, what I cannot figure out is how to specify the UUID while connecting the socket. This is something quite straightforward on other contexts, as it happens when using Android libraries; however, with BlueZ I haven't found examples on the web.
Thanks for the help!
Stefano
-- added some details in a reply... don't know if it's right or not; if not, sorry
thanks for your help!
In my post I said I wanted to connect a socket with a specified UUID since I had in mind a function like createRfcommSocketToServiceRecord as can be found in:
http://developer.android.com/reference/android/bluetooth/BluetoothDevice.html#createRfcommSocketToServiceRecord%28java.util.UUID%29
which returns a socket given a certain UUID. I am developing two softwares, one being the client and the other the server, therefore it's a service I am creating, not a standard one. I publish such service on the server with a specified UUID, and I would like to connect to it from the client. The server is running fine, since with an android platform, exploiting the mentioned createRfcommSocketToServiceRecord method, I am able to connect to the server with the right service.
The example you posted is very clear as well, but unfortunately it is in Python, while (I forgot to point out) I am using Bluez as a C library. I am able to exploit the SDP and inspect services on a remote server; however, when it is the time of setting up the socket, I don't see how to specify the port. I thought about the rc_channel, but as far as I understood it is the bluetooth channel (ranging from 1 to 11 or something similar). Could you please point out Where I should be able to specify the port while creating the socket in the client? And where am I able to find the right port in the complex structure the sdp is dealing with? -- referred to:
http://people.csail.mit.edu/albert/bluez-intro/x604.html
Thanks again for the help!
You don't connect sockets by UUID. You use a socket to connect to remote device and browse its SDP to discover the UUIDs it offers, and map that to a socket port. Here's an example of this process using PyBluez, python wrappers above BlueZ
http://people.csail.mit.edu/albert/bluez-intro/x290.html
I have recently been working on a nodejs app which uses open socket connections for all of its communication. The index is served up through nginx. I want to benchmark the ability of the server to handle a high amount of load which means I would end up testing my application's ability to manage open sockets, and not its ability to serve up the index file.
Does anyone know of a reliable way to do this?
You can try wsbench as solution, but you don't necessarily use wsbench for all transports.
For example:
node wsbench -c 100 -r 10 ws://example.com:8080/socket.io/websocket