https://github.com/alexdlaird/java-ngrok-example-tcp-server-and-client
TCP Server and Client example for java-ngrok
https://github.com/alexdlaird/java-ngrok-example-tcp-server-and-client
education java java-ngrok localhost localtunnel reverse-proxy tcp tcp-client tcp-server tunnel tunneling webhook
Last synced: 4 months ago
JSON representation
TCP Server and Client example for java-ngrok
- Host: GitHub
- URL: https://github.com/alexdlaird/java-ngrok-example-tcp-server-and-client
- Owner: alexdlaird
- License: mit
- Created: 2021-08-26T17:40:53.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2024-04-15T10:31:43.000Z (over 1 year ago)
- Last Synced: 2024-05-02T05:50:26.130Z (over 1 year ago)
- Topics: education, java, java-ngrok, localhost, localtunnel, reverse-proxy, tcp, tcp-client, tcp-server, tunnel, tunneling, webhook
- Language: Java
- Homepage: https://github.com/alexdlaird/java-ngrok
- Size: 115 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/alexdlaird/java-ngrok-example-tcp-server-and-client/actions/workflows/build.yml)
# java-ngrok Example - TCP Server and Client
This is an example project that shows how to easily integrate [`java-ngrok`](https://github.com/alexdlaird/java-ngrok)
with a simple TCP Server and Client.## Getting Started
This is an example of a simple TCP ping/pong server. It opens a local socket, uses `ngrok` to tunnel to that socket,
then the client/server communicate via the publicly exposed address.This project will reserve (and then release) its own TCP address using `ngrok`'s API.
Build the application with:
```sh
make build
```Start a socket server with:
```sh
USE_NGROK=true \
NGROK_AUTHTOKEN="my-auth-token" \
NGROK_API_KEY="my-api-key" \
java -jar build/libs/java-ngrok-example-tcp-server-and-client-1.0.0-SNAPSHOT.jar server
```It’s now waiting for incoming connections, so start a client in another terminal to send it something. Start a socket
client with:```sh
USE_NGROK=true \
HOST="1.tcp.ngrok.io" \
PORT=12345 \
java -jar build/libs/java-ngrok-example-tcp-server-and-client-1.0.0-SNAPSHOT.jar client
```And that’s it! Data was sent and received from a socket via your `ngrok` tunnel.