How To Install python-websockify on Ubuntu 18.04

In this tutorial we learn how to install python-websockify on Ubuntu 18.04. python-websockify is WebSockets support for any application/server - Python 2

Introduction

In this tutorial we learn how to install python-websockify on Ubuntu 18.04.

What is python-websockify

python-websockify is:

websockify was formerly named wsproxy and was part of the noVNC project.

At the most basic level, websockify just translates WebSockets traffic to normal socket traffic. Websockify accepts the WebSockets handshake, parses it, and then begins forwarding traffic between the client and the target in both directions.

Websockify supports all versions of the WebSockets protocol (Hixie and HyBi). The older Hixie versions of the protocol only support UTF-8 text payloads. In order to transport binary data over UTF-8 an encoding must used to encapsulate the data within UTF-8.

With Hixie clients, Websockify uses base64 to encode all traffic to and from the client. This does not affect the data between websockify and the server.

With HyBi clients, websockify negotiates whether to base64 encode traffic to and from the client via the subprotocol header (Sec-WebSocket-Protocol). The valid subprotocol values are ‘binary’ and ‘base64’ and if the client sends both then the server (the Python implementation) will prefer ‘binary’. The ‘binary’ subprotocol indicates that the data will be sent raw using binary WebSocket frames. Some HyBi clients (such as the Flash fallback and older Chrome and iOS versions) do not support binary data which is why the negotiation is necessary.

This package provides the Python 2 module.

There are three methods to install python-websockify on Ubuntu 18.04. We can use apt-get, apt and aptitude. In the following sections we will describe each method. You can choose one of them.

Install python-websockify Using apt-get

Update apt database with apt-get using the following command.

sudo apt-get update

After updating apt database, We can install python-websockify using apt-get by running the following command:

sudo apt-get -y install python-websockify

Install python-websockify Using apt

Update apt database with apt using the following command.

sudo apt update

After updating apt database, We can install python-websockify using apt by running the following command:

sudo apt -y install python-websockify

Install python-websockify Using aptitude

If you want to follow this method, you might need to install aptitude first since aptitude is usually not installed by default on Ubuntu. Update apt database with aptitude using the following command.

sudo aptitude update

After updating apt database, We can install python-websockify using aptitude by running the following command:

sudo aptitude -y install python-websockify

How To Uninstall python-websockify on Ubuntu 18.04

To uninstall only the python-websockify package we can use the following command:

sudo apt-get remove python-websockify

Uninstall python-websockify And Its Dependencies

To uninstall python-websockify and its dependencies that are no longer needed by Ubuntu 18.04, we can use the command below:

sudo apt-get -y autoremove python-websockify

Remove python-websockify Configurations and Data

To remove python-websockify configuration and data from Ubuntu 18.04 we can use the following command:

sudo apt-get -y purge python-websockify

Remove python-websockify configuration, data, and all of its dependencies

We can use the following command to remove python-websockify configurations, data and all of its dependencies, we can use the following command:

sudo apt-get -y autoremove --purge python-websockify

References

Summary

In this tutorial we learn how to install python-websockify package on Ubuntu 18.04 using different package management tools: apt, apt-get and aptitude.