MQTT in paho can't connect in connection - eclipse

I am trying to use the MQTT javascript client from Paho. I see a example from HiveMQ, you can check it here - - http://www.hivemq.com/demos/websocket-client/
It seems to be working, however when I set the host as: test.mosquitto.org:1883, which is a mqtt broker service at mosquitto, it fails.
When I tried to connect to this mosquitto service, it gives me a error on connection - connect failed: AMQJS0007E, Socket error: undefined.

Mosquitto does not support MQTT over WebSockets out of the box. So Roger is using lighttpd with the mod_websocket module to forward.
This means that the port will be port 80 not 1883
But having just had a quick look at http://test.mosquitto.org/ws.html it seams that the lighttpd instance may be down at the moment as the demo is not working.
If you want to run your own local copy of mosquitto for testing there is a link on that page with instructions on how to build mod_websocket for lighttpd or a ubuntu ppa to download it from.
EDIT:
Mosquitto now includes WesbSocket support built in, but you will need to add an extra listener to enable it, e.g.
listener 8883
protocol websockets

As hardillb says, you need to use port 80. The full url you should use is
ws://test.mosquitto.org/mqtt
If you are using m2m.eclipse.org as Andy suggests (which is actually using apache with websockets support) then you should use
ws://m2m.eclipse.org/ws

You could try the same thing against m2m.eclipse.org which I think has websocket support switched on via lighthttpd as well.

Related

Jupyter websocket issue

I have a debian Jupyter running on port 8888.
I want to make it easier to connect to my server,so I have a node.js
app running that forwards request to jupyter.mydomain.com:80 to
port 8888, andother domains to other ports.
This way I dont have to remember the ports of different apps, and instead
can refer to the server with different dns names. All the different names
are setup as a links in the dns server.
Now Jupyter works this way; but the Websockets that report the result of
calculations do not due to security error.
Is there any setting how I can get this to work?
Regards
Andreas
node-http-proxy is a node proxy that supports websockets. Your node app that's proxying requests must also proxy websocket connections.
JupyterHub is a multi-user server for spawning and authenticating single-user notebook servers, and it uses configurable-http-proxy, a subclass of node-http-proxy that adds some live configuration, to relay connections to notebooks. If you use NHP or CHP for your proxy app, the websockets should work.
From the node-http-proxy readme:
You can activate the websocket support for the proxy using ws:true
in the options.
//
// Create a proxy server for websockets
//
httpProxy.createServer({
target: 'ws://localhost:9014',
ws: true
}).listen(8014);

How do I access the database from my browser?

I noticed with Postgres and other databases, the database itself runs a local version of a server.
For example, mine is running on localhost:5432.
Curiously, I went to my web browser and tried typing in that address to see what I'd get, but I got a response that "This Web Page is Not Available".
I also tried things like localhost:5432/mydata but also to no avail.
Shouldn't I be able to see something if I visit the database through my web browser? If yes, how do you do it? If not, why not?
Postgres is a service running on a port. A web server is also a service running on a port (80 and/or 443 usually). There are a lot of things running on various ports on any server, heck, on any single computer. That doesn't mean that everything is interchangeable. Ports 80 and 443 are commonly agreed to serve HTTP(S) connections. HTTP is a specific protocol which specifies how two things can communicate on a specific port. Postgres is not speaking HTTP; you need to speak Postgres' particular protocol if you want to talk to it. The browser does not speak that protocol, and Postgres doesn't by default offer communication in any protocol a browser understands.
A web browser expects to "talk" to servers using a protocol it supports. Webbrowsers support obviously http. Some do support other protocols, like ftp. But your postgres does not speak http. So you don't see anything. The port number is just telling over which channel the server is accessible. Any protocol can be routed over any port, but usually http can be reached over port 80. Your postgress over port 5432.

Run play framework app at specified socket

Play documentation only describes changing the default 9000 port to some other by -Dhttp.port <port> argument.
Is it possible to use unix socket instead of port? Due to administrator's policy every application has to provide socket which is then used by nginx used as front end web server.
I've found a chapter in play docs about using nginx but again - it only covers app running at port.
I'm using play 2.2.0.
There is no support for listening to unix sockets in Netty which Play uses as http server. There is a third party library for Netty but you will probably not be able to plug it into Play without some serious messing around with the framework internals.
https://github.com/Flipkart/phantom/wiki/Unix-domain-socket-transport-for-netty

Bluetooth: how to create a socket for connecting to a service with specific UUID with Bluez?

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

Is it possible connect to google talk xmpp server using BOSH?

I'm using SMACK library (JAVA) to handle XMPP connection on an android platform and i would like to know if google support BOSH.
Recently my mobile operator locked some ports and now i'm limited to 80 and 8080 ports so BOSH would be a great solution.
thanks for your time
Well after some research and tests i conclude that is possible to connect using port 80 instead 5222 recommended by google. Connecting via port 80 doesn't use BOSH so you can use any XMPP client library to connect over.