Take the 2-minute tour ×

I am trying to create a chrome extension using HTML5 WebSockets and can't get a clear example. I have a few questions that I hope the community can answer for me in a clear and concise manner.

  1. The WebSocket Server, can that be added to an Google Chrome Extension? Either way can someone tell me exactly what is needed to make a Server or include a decent link to a clear example?
  2. When connecting to the WebSocket Server everyone always has something like ws://localhost:port number. Is the ws required or what is the point of that? I don't know if this is meant to be a file location or what. And just to make sure the IP address and port number is where your server is located and what port it's listening on right?
  3. Websites like pusher at http://www.pusher.com/ is that just a way to send communication between two different devices and you still need a server or does this replace a server/can this replace a server.

I have done quite a bit of Google searching so its not like I don't know anything about this topic. I just don't understand all the different things and the websocket API does not give a definition of any of its functions and doesn't really explain anything about how to use it.

Some Links I have checked out: http://dev.w3.org/html5/websockets/ , http://jnext.org/index.html , http://www.pusher.com/ , http://jwebsocket.org/ , http://joshuakehn.com/blog/view/2/WebSocket-Tutorial-with-Node-js

I need something that does not need to be installed onto a computer. All server/client/coding needs to be javascript that can be placed into a chrome extension. Thank you for anyone who can help me.

share|improve this question
do you feel that your question was sufficiently answered? If not, is there anything that you feel is missing to fully answer your question? –  kanaka Feb 29 '12 at 23:20

2 Answers 2

  1. It seems like you're saying you want to run a websocket server on the client? That's not going to be possible. You can't launch processes on a user's machine from a browser.

  2. ws indicates to use the web sockets protocol just like http indicates to use hyper text transfer protocol or ftp indicates to use file transfer protocol.

  3. Pusher is a service that hosts and runs a web socket server for you. You could also write your own web socket server and install it on your own server.

share|improve this answer
well I do not want both the client and the server in the extension I want the server in the extension. The client will be elsewhere trying to access the extension. –  eric Jun 13 '11 at 22:03
You're out of luck with that. Even if you could install a server on the user's machine (which you can't) you'd have to deal with issues like ports being open and able to accept incoming connections through their firewall, etc. You need to have the web socket server located elsewhere and then their browser can connect to the server via the JavaScript web socket api. –  Craig M Jun 13 '11 at 22:07
  1. There is no API to create a WebSockets server as a Chrome extension. websockify contains a python class for creating WebSocket servers easily. See the tests/echo.py example.

  2. The ws:// prefix indicates an unencrypted WebSockets connection. Likewise, wss:// is for encrypted connections (using TLS/SSL). One or the other is required.

  3. Pusher is a WebSockets service that provides a layer on top of raw WebSockets that does session management for you. You do not need a separate WebSockets server.

share|improve this answer
so if I were to sign up for Pusher I would not need to host a server? Pusher would accept a message from an outside source and send it to the extension? –  eric Jun 13 '11 at 22:04
The "outside source" will still need to be a WebSockets client of some sort (browser or other). But yes, it could send a message to Pusher which would then send the message to the other connected clients (browsers). I.e. you could have a special client that sends stock prices and the other clients could connect and receive those messages. Note that Pusher is commercial if you want to have more than 20 connections (clients) or 100,000 messages per day. –  kanaka Jun 13 '11 at 22:13

Your Answer


