I would like to connect to to irc, icq, sip, etc services using WebSockets. Assuming I have some sort implementation of those protocols in JavaScript ? Is that possible? I don't seems to understand limitations of WebSockets comparing to regular sockets.
1) A web browser connects to it, 2) It then connects to an IRC network, 3) The data between the two connections are then passed back and forth with any required encoding. Most IRC networks currently do not support websocket connections or will only support native websockets.
All you have to do is call the WebSocket constructor and pass in the URL of your server. // Create a new WebSocket. var socket = new WebSocket('ws://echo.websocket.org'); Once the connection has been established, the open event will be fired on your Web Socket instance.
The WebSocket protocol is an independent TCP-based protocol. Its only relationship to HTTP is that its handshake is interpreted by HTTP servers as an Upgrade request. By default the WebSocket protocol uses port 80 for regular WebSocket connections and port 443 for WebSocket connections tunneled over TLS [RFC2818].
In WebSocket, communication occurs at both ends, which makes it a faster protocol. In HTTP, the connection is built at one end, making it a bit sluggish than WebSocket. WebSocket uses a unified TCP connection and needs one party to terminate the connection. Until it happens, the connection remains active.
No, you can't, at least not directly.
WebSockets allow real-time messaging between a browser and a WebSocket server, but they have their own layer 7 protocol for encapsulating those messages.
They don't provide access to a pure TCP (or UDP) socket over which you can implement existing protocols.
Absolutely!
The caveat is that you need something to bridge between the WebSocket transport protocol of the browser and the raw TCP socket of the existing service. For example, something like websockify (disclaimer: I created websockify). Another caveat is that websockify only supports TCP targets (WebSocket is TCP only right now so supporting UDP targets would be a little odd anyways).
The websockify project actually includes two proof of concept HTML/Javascript pages to communicate with IRC and telnet. If you are interested in leveraging websockify to build HTML/Javascript clients for some common TCP protocols, I might even pull them into the websockify repo as examples (assuming they are well coded and under an open source license.
An alternative to websockify is to integrate websocket server-side support directly into the servers you wish to communicate with. It's not all that difficult to add support. WebSocket has a very simple framing and while the handshake is compatible with HTTP servers it's actually much more restricted and simple and doesn't require a full HTTP parser. For example, libvncserver 0.9.9 now supports both regular VNC connections and VNC connections over WebSocket. This allows noVNC (which I also created) to connect directly to a libvncserver based VNC server without requiring websockify.
Inspircd has an unofficial module you can install called m_websockets
, to allow connection. A server that has the module installed and setup will allow you to connect to the server via webbsockets.
https://github.com/barosl/inspircd-m_websocket
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With