Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

9 Commits

Repository files navigation

Websockify Server in Java

No Maintenance Intended

This is a proof of concept implementation of a Websockify server in Java. The server acts as a bridge between WebSockets and TCP connections, allowing for bidirectional communication between WebSocket clients and TCP servers.

✨ Features

  • WebSocket to TCP bridge:
    • The server accepts WebSocket connections and forwards the received messages to a specified TCP server.
  • TCP to WebSocket bridge:
    • The server listens for incoming TCP connections and relays the received data to the WebSocket clients.

✅ Software tested

  • noVNC (HTML5 VNC Client, works)

📜 Getting Started

To use this Websockify server, follow the steps below:

  1. Clone the repository: git clone https://github.com/morihofi/WebsockifyJava
  2. Open it in your favorite IDE

Tunnel TCP to WebSocket

publicstaticvoidmain(String[] args) {
//Websocket server settingsStringwsHost = "localhost";
intwsPort = 8090;
WebSocketServerserver = newWebsockifyServer(newInetSocketAddress(wsHost, wsPort), "192.168.178.1", 80);
server.run();
}

This tunnels traffic from 192.168.178.1:80/TCP to a Websocket running on Port 8090 on your machine

Tunnel WebSocket to TCP

publicstaticvoidmain(String[] args) throwsIOException {
StringwebsocketUrl = "ws://localhost:8090";
ServerSocketserverSocket = newServerSocket(7070);
while (true){
try {
Socketsocket = serverSocket.accept();
newThread(() -> {
//Handle connection in seperate Threadtry {
WebsockifyClientclient = newWebsockifyClient(newURI(websocketUrl), socket);
client.run();
} catch (URISyntaxExceptione) {
}
}).start();
} catch (IOExceptione) {
thrownewRuntimeException(e);
}
}
}

This connects to ws://localhost:8090 and opens a TCP Socket on your machine on port 7070

About

Another Websockify implementation in Java (includes Websocket to TCP and TCP to Websocket bridge)

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages