tcp socket server to test html5websocket - html

Which is best tcp socket server to testing html5websocket? I developing a html5socket based client that will interact with tcp. So I want first a testing server. I am good in PHP but not in sockets programming. So I used PHPwebsocket downloaded from google code. I tried it using its own client and server for testing but it suddenly disconnects and not work as intended so is there any other socket server to test HTML5 websocket client? Which one is better, I can use a python based, or java based tcp server or if in PHP then that can be more convenient. And please tell me what else I need to test HTML5 websocket. I am newbie in sockets. So my concepts are not so clear.
thanks for any advise.

If you want to self host then:
pywebsocket - Python
jwebsocket - Java
jetty with WebSockets - Java
You could connect to the Pusher hosted WebSocket API to see if you can connect. More information on the endpoints and Pusher protocol here:
http://pusher.com/docs/pusher_protocol
You would need to sign up for a free Pusher sandbox account to do this though.

You say you want to "interact with tcp". Do you have specific protocols in mind? If using JMS, XMPP, or AMQP, the Kaazing WebSocket Gateway provides these industry standard APIs and protocols in the browser out-of-the-box. For example, using JMS, you can build pretty complex messaging applications without a single line of server-side code. Everything can run in the client (typically in JavaScript in the browser).
Here are some examples showcasing the power of extending rich business protocols all the way to the browser.
Also, the Kaazing gateway comes with free development license; fully functional server for up to 50 concurrent connections, no functionality or time restrictions.

Related

Hosting html file over mosquitto

I just found that mosquitto had got a websockets upgrade which allows it to
host the HTTP services.
I tried hosting a html file using the websockets feature on the port 8080.
The mosquitto broker seems to start fine and the mqtt services on the other ports seem to function properly. But when i try to access the html file over the localhost I get the a response saying no data sent by the server.
I am not sure where my mistake lies..Any ideas?
Mosquitto is not a HTTP server, it can not serve generic files.
The HTTP listener is only there to facilitate an upgrade to the websocket protocol in order to run MQTT over a websocket connection.
You might want to look out for a different broker that is flexible enough to do what you're looking for. I don't know of any MQTT broker that allows you to do that out of the box, but many are fairly extensible. For one I can talk about is VerneMQ, as I am one of the core developers. Developing a simple VerneMQ plugin that serves some static files over HTTP is a matter of a few lines of code, as the plugin only requires to setup some configuration for the internal webserver.
However, unfortunately we haven't yet documented this feature. But feel free to drop us a line if such an approach sounds interesting for you.
Cheers,
Andre

How to connect to my MQTT Broker in Openshift

Following these two tutorials (https://www.anavi.org/article/182/ and http://wei-meilin.blogspot.tw/2014/05/red-hat-openshift-xpaas-simple-mqtt.html) I have installed a MQTT Broker using JBoss Fuse.
Although my mqtt-container disappears after a while (I don't know why) I can make a port-forwarding and test the broker.
But I would like to know how to connect directly to the broker. Do you know how to do it?
I have tried this tutorial (http://training.runcloudrun.com/advanced/16-Network-and-Protocols.md.html - AMQ Example) but I don't have access to "/var/lib/openshift/.httpd.d/sniproxy.cfg"
I am the author of the first tutorial that you pointed out. If you want to use MQTT without local port forwarding please have a look at the remark at the article on my blog and the AMQ cartridge that demonstrates the SNI features:
The port forwarding is not convenient for real life cases, especially if the MQTT clients are working on embedded devices such as microcontrollers and it is recommended to use a SNI Proxy as explained here: http://training.runcloudrun.com/advanced/16-Network-and-Protocols.md.html
I was using Online Openshift and that feature is only available for Enterprise edition.
Why doesn't Openshift have this feature (complete) in the Online mode?
One way to work around is to use the mqtt over websocket feature with a DIY cartridge. See the SO question "How can I access socket through Openshift" for some pointers to further details about how to run websocket on openshift.
The mosquitto seems to have implemented the websocket feature though I have not verified by testing it out.

html5 WebSocket

I already have a server with port and want to write a web app to get the information form the port. Will this be possible with WebPorts?
The Client doesn't even need to talk back to the server, which is the whole point of websockets I would imagine, but since I already have the ports setup, I might be easier and cleaner to just connect and get the info without having to refresh.
WebSockets are not intended as clear TCP channels over which other existing protocols can be implemented.
WebSockets are designed to allow messages to be sent between a client and server, where an event is raised each time a message is received.
Hence a WebSocket client cannot simply connect to an existing TCP server - that server also has to speak the WebSocket protocol.
You could of course write a WebSocket-based server that does nothing but act as a proxy to existing network services.
I think you want websockify which is a WebSocket to plain TCP socket bridge/proxy. It also allows sending and receiving of binary data with the older version of the WebSocket protocol which hadn't yet added direct binary data support.
Disclaimer: I created websockify.

Hosting a Silverlight database application that works with MySQL

I have a basic hosting package that gives me access to create a MySQL database. I can of course host silverlight applications on any site. But how can I work with a database from within Silverlight? I cannot run any service on my hosting provider, they only allow php or perl scripts.
You can use the C# webclient to make HTTP calls to a PHP page hosted on the server. The PHP page can proxy queries/results between the silverlight client and the mysql database.
remember, just because it's not a SOAP/WCF "service" does not mean that it's not a web service. Look into PHP based REST solutions for some nice alternatives that can easily be invoked via silverlight:
http://www.bing.com/search?q=PHP+REST
Edit: As #Spencer Ruport correctly points out in the comments, you of course have to be wary of the fact that the web service will be exposed to the public, and anyone can easily sniff the http traffic between your silverlight application and the server. This enable them to call your service directly so be sure to think about authentication and what it means in the context of your app/data
You can use the WebClient class in silverlight to communicate to a php service. Here is the first google result I found: link

Do I need a server to use HTML5's WebSockets?

When using WebSockets, will I need to write server code? In other words, will the JavaScript in my client application need to connect to a specialized server, or will my existing Apache server work to support this?
The server has to support web sockets. After a first handshake in HTTP, the server and the client open a socket connection. The server must be able to understand and accept this handshake.
In my last project we run quite successfully web socket connections using the last Jetty version.
27/02/2014:
Now I'm also implementing websockets under .net with XSockets.net and works like a charm, you don't even need a web server (self hosting). The WebSocket implementation of ASP.NET works also quite good.
Yes,you need to write server code.
I recommend another web socket server based on php: ratchet.
And this link is benchmarking webSocket servers between ratchet and sockJS.
Complete list of client & server side codes and browsers support please check this link
Of course you need a WebSocket server. But there are many free websocket server in different language, like jWebSocket in Java and SuperWebSocket in .NET, you can use them directly.
There are some plugins currently being developed on google code for Apache...
By definition websockets like normal sockets are client-server so yes, you need a server. However there is an alternative to waiting for Apache plugins.
I am using a hosted server http://www.achex.ca. Its free and you have tutorials in javascript on how to use the server. A good start for websockets development.
The server is basically a message router and you can connect to it and use it as a meeting point for all your websocket clients.
Short Answer: Yes, You need a specialized server, Apache does not come with websockets.OR The alternative, check out www.achex.ca.
In such a situation the role of server comes when :
In HTML 5,WebSocket like a fone(2-way comm.) not walky-talky.
http protocol upgraded to websocket protocol.(wss:// from ws://)
SERVER should be able to open duplex channel and hence AGREE with duplex communication.
Please go through this link : http://www.html5rocks.com/en/tutorials/websockets/basics/
If using php please look at RATCHET.
Thanks.
The Perl Mojolicious server supports web sockets, and implementations can be only a few lines long.
Node.js has several WebSocket libraries but details of the latest, greatest, most supportive of the latest spec vary, so choose carefully.
Apache Active MQ is also worth a look, along with the stomp protocol it implements.