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

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.

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 enable https connections in phpstorm's built in web server

My php application has to work over https. However phpstorm's build in web server does not serve https connections.
I even enabled two different built in web servers over ports 80 and 443, but https://localhost does not work while http://localhost works.
How to configure built in web server for https?
The PHP built-in webserver has zero support for SSL. There are a few ways to fake it, none of them good. The idea seems to be that a development server (which it is intended to be) has no need of SSL, but someone clearly overlooked the need to develop handling and the like for SSL based connections.
A simple example would be Wordpress running with the FORCE_SSL_ADMIN flag set to true.
If your development requires it I suggest installing a more robust webserver for your development.

Connecting from Flash to IRC server

I'm looking for a way to connect from flash to an IRC server.
The common solution was to use a tunneling service which uses comet/websockets like:
pusher.com
tech.kaazing.com/documentation/dragonfire/howto-irc.html
www.lightstreamer.com
However, since this product is meant for flash, can I connect directly to the irc server instead of going through the tunneling service in the middle?
One proof of concept that i found was lightirc, but they doesn't make it clear if they serve as a long-polling proxy in the middle or the client connects directly to the irc server. The only thing they mention is that I should put crossdomain.xml on the irc server side to bypass the flash security setting, but does it means the client connects to it directly?
Any idea if

tcp socket server to test html5websocket

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.

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