Code Monkey home page Code Monkey logo

tl-open-source / tl-rtc-file Goto Github PK

View Code? Open in Web Editor NEW
2.2K 9.0 215.0 32.89 MB

WebRTC P2P online web media streaming tool (for files, video, screen, live streaming, text) with management and statistical monitoring capabilities.

Home Page: https://im.iamtsm.cn/website/index.html

License: MIT License

Shell 3.35% JavaScript 67.94% CSS 3.64% HTML 17.54% Vue 3.00% TypeScript 4.03% Batchfile 0.48% Dockerfile 0.02%
webrtc p2p filetransfer websocket node turnserver demotool

tl-rtc-file's Introduction

tl-rtc-file-tool (tl webrtc file(media) tools)

DemoDocumentDockerHub中文文档 | QQ Group: 624214498

Table of Contents

Background

This project was developed based on the topic of the graduation project in 2020. It allows file transfer using WebRTC in web applications and supports transferring large files.

Advantages

Fragmented transmission, cross-platform, platform-independent, easy to use, no speed limit in the local network (up to over 70 MB/s in the LAN), supports private deployment, supports drag-and-drop sending of multiple files, web file preview. Many additional features have been added, such as local screen recording, remote screen sharing (zero-latency), remote audio and video calls (zero-latency), live streaming (zero-latency), password-protected rooms, OSS cloud storage, relay service settings, WebRTC detection, WebRTC statistics, text transmission (group chat, private chat), public chat, remote whiteboard, AI chatbox, feature-rich admin panel, real-time execution log display, robot alert notifications, and more.

Pre-deployment Considerations

Whether it's self-deployment, Docker deployment, or other script deployments, you need to modify the corresponding configurations in tlrtcfile.env before performing the following operations. Further configuration modifications and service restarts are required.

Of course, you can also use the default configurations without modifications, but the default configurations are only suitable for testing on localhost. They won't be accessible to others, making it impossible for others to use. Therefore, if you intend to deploy on a server for local network or public network users, you must configure tlrtcfile.env accordingly.

Self-Deployment

Installing Dependencies

Install Node.js 14.21.x or above, and npm. Then, navigate to the project directory and run the following command:

cd svr/

npm install

For the first run, execute the following command:

npm run build:pro

If you need to develop or modify the frontend pages, use this command. If not, you can skip this step:

npm run build:dev

Starting the Service

Start the following two services. Choose one mode to start. The only difference between them is that the HTTPS mode is required to use features like audio/video streaming, live streaming, and screen sharing. Other features are not affected.

After starting in HTTP mode, access the service at http://your_machine_ip:9092.

  • Start the API and socket services:
npm run http-api
npm run http-socket

Or, start in HTTPS mode and access the service at https://your_machine_ip:9092.

  • Start the API and socket services:
npm run https-api
npm run https-socket

Docker Deployment

Currently, both official images and self-built images are supported. For official images, there are two ways to operate: docker script startup and docker-compose startup.

One-Click Docker Script

Navigate to the bin/ directory and execute the auto-pull-and-start-docker.sh script:

chmod +x ./auto-pull-and-start-docker.sh
./auto-pull-and-start-docker.sh

Using docker-compose

In the main directory, execute the corresponding command based on your Docker Compose version:

  • For Docker Compose V1:
docker-compose --profile=http up -d
  • For Docker Compose V2:
docker compose --profile=http up -d

Self-Building and Starting the Image

Navigate to the docker/ directory and execute the corresponding command based on your Docker Compose version:

  • For Docker Compose V1:
docker-compose -f docker-compose-build-code.yml up -d
  • For Docker Compose V2:
docker compose -f docker-compose-build-code.yml up -d

Other Deployment Methods

In addition to the manual installation, Docker official images, and self-built Docker images, there are other methods such as automatic scripts and one-click deployments on hosting platforms.

After downloading the project, navigate to the bin/ directory and choose the appropriate system script to execute. It will automatically detect the environment, install dependencies, and start the service.

Automatic script for Ubuntu (e.g., Ubuntu 16)

  • If the script doesn't have execution permission, run the following command:
chmod +x ./ubuntu16/*.sh
  • If using HTTP, execute this script:
./auto-check-install-http.sh
  • If using HTTPS, execute this script:
./auto-check-install-https.sh
  • To stop the service:
./auto-stop.sh

Automatic script for Windows

  • If using HTTP, execute this script:
windows/auto-check-install-http.bat
  • If using HTTPS, execute this script:
windows/auto-check-install-https.bat

One-Click Deployment on Zeabur Platform

Deploy on Zeabur

Other Configuration Options

Configuring the Database (Optional)

You need to install MySQL database manually, create a database named webchat, and then modify the database-related configurations in tlrtcfile.env.

Admin Panel (Optional)

Prerequisite: Database configuration must be enabled.

Modify the admin panel-related configurations in tlrtcfile.env. After starting, enter the configured room number and password to access the admin panel.

WeChat Notifications (Optional)

If you need to set up notification for access and error alerts, you can create a WeChat Work robot and get an API key. Modify the WeChat notification configurations in tlrtcfile.env.

OSS Cloud Storage (Optional)

The project currently supports Seafile storage integration, and future updates will include support for Alibaba Cloud, Tencent Cloud, Qiniu Cloud, and self-hosted server storage methods. Modify the OSS storage configurations in tlrtcfile.env.

Chat-GPT (Optional)

Integrated with the OpenAI API, this project includes a chat dialog. Modify the OpenAI configurations in tlrtcfile.env.

Configuring turnserver (Optional for LAN, Required for WAN)

There are two ways to generate TURN server credentials: fixed credentials (recommended) and time-limited credentials. Choose one method. The following example uses Ubuntu.

Install coturn:

sudo apt-get install coturn

For time-limited credentials, modify the configuration file docker/coturn/turnserver-with-secret-user.conf.

  • Modify the fields in the configuration file:
`listening-device`, `listening-ip`, `external-ip`, `static-auth-secret`, `realm`
  • Start the turnserver:
turnserver -c /path/to/conf/turn/turnserver-with-secret-user.conf

For fixed credentials, modify the configuration file docker/coturn/turnserver-with-fixed-user.conf.

  • Modify the fields in the configuration file:
`listening-device`, `listening-ip`, `external-ip`, `user`, `realm`
  • Generate a user:
turnadmin -a -u username -p password -r realm_in_config_file
  • Start the turnserver:
turnserver -c /path/to/docker/coturn/turnserver-with-secret-user.conf

After setting up coturn, configure the WebRTC-related information in the corresponding tlrtcfile.env configuration.

Overview Diagram

image

License

MIT License Copyright (c) 2020 ~ 2023 iamtsm

Disclaimer

Disclaimer

tl-rtc-file's People

Contributors

iamtsm avatar nigh avatar sage417 avatar xgchange avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tl-rtc-file's Issues

请教 Docker 启动后 ,nginx 该如何配置.

docker compose --profile=http up

#PROXY-START/


location /
{
    proxy_pass http://127.0.0.1:9092;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header REMOTE-HOST $remote_addr;
    
    add_header X-Cache $upstream_cache_status;
    
    #Set Nginx Cache
    
    	add_header Cache-Control no-cache;
}

location /ws {
  proxy_pass http://127.0.0.1:8444;
  proxy_http_version 1.1;
  proxy_set_header Upgrade $http_upgrade;
  proxy_set_header Connection "Upgrade";
  proxy_set_header Host $host;
}

#PROXY-END/

但是发现只有Chrome正常的.
手机 和 电脑的Safari 连接时报错. docker 也没有日志输出
image

env 文件没有改

#-----------------以下为基础配置-----------------#
## api服务端口
tl_rtc_file_api_port=9092
## websocket服务端口
tl_rtc_file_socket_port=8444
## websocket服务地址
tl_rtc_file_socket_host=127.0.0.1:8444


#-----------------以下为webrtc相关配置-----------------#
## webrtc-stun中继服务地址
tl_rtc_file_webrtc_stun_host=stun:127.0.0.1:3478
## webrtc-turn中继服务地址
tl_rtc_file_webrtc_turn_host=turn:127.0.0.1:3478?transport=udp
## webrtc中继服务用户名
tl_rtc_file_webrtc_turn_username=tlrtcfile
## webrtc中继服务密码
tl_rtc_file_webrtc_turn_credential=tlrtcfile
## webrtc中继服务Secret
tl_rtc_file_webrtc_turn_secret=tlrtcfile
## webrtc中继服务帐号过期时间 (毫秒)
tl_rtc_file_webrtc_turn_expire=86400000


#-----------------以下为mysql数据库相关配置-----------------#
## 是否开启数据库
tl_rtc_file_db_open=false
## 数据库地址
tl_rtc_file_db_mysql_host=mysql
## 数据库端口
tl_rtc_file_db_mysql_port=3306
## 数据库名称
tl_rtc_file_db_mysql_dbName=webchat
## 数据库用户名
tl_rtc_file_db_mysql_user=tlrtcfile
## 数据库密码
tl_rtc_file_db_mysql_password=tlrtcfile

#-----------------以下为oss相关配置-----------------#
## oss-seafile存储库ID
tl_rtc_file_oss_seafile_repoid=
## oss-seafile地址
tl_rtc_file_oss_seafile_host=
## oss-seafile用户名
tl_rtc_file_oss_seafile_username=
## oss-seafile密码
tl_rtc_file_oss_seafile_password=

## oss-alyun存储accessKey
tl_rtc_file_oss_alyun_AccessKey=
## oss-aly存储SecretKey
tl_rtc_file_oss_alyun_Secretkey=
## oss-aly存储bucket
tl_rtc_file_oss_alyun_bucket=

## oss-txyun存储accessKey
tl_rtc_file_oss_txyun_AccessKey=
## oss-txyunt存储SecretKey
tl_rtc_file_oss_txyun_Secretkey=
## oss-txyun存储bucket
tl_rtc_file_oss_txyun_bucket=

## oss-qiniuyun存储accessKey
tl_rtc_file_oss_qiniuyun_AccessKey=
## oss-qiniuyunt存储SecretKey
tl_rtc_file_oss_qiniuyun_Secretkey=
## oss-qiniuyun存储bucket
tl_rtc_file_oss_qiniuyun_bucket=


#-----------------以下为管理后台相关配置-----------------#
## 管理后台房间号
tl_rtc_file_manage_room=tlrtcfile
## 管理后台密码
tl_rtc_file_manage_password=tlrtcfile


#-----------------以下为openai相关配置-----------------#
## openai-key,如果有多个key,逗号分隔
tl_rtc_file_openai_keys=


#-----------------以下为企业微信通知相关配置-----------------#
## 企业微信通知开关
tl_rtc_file_notify_open=false
## 企业微信通知机器人KEY,正常通知,如果有多个key,逗号分隔
tl_rtc_file_notify_qiwei_normal=
## 企业微信通知机器人KEY,错误通知,如果有多个key,逗号分隔
tl_rtc_file_notify_qiwei_error=

是否支持内网传输

我看这篇文章 https://zhuanlan.zhihu.com/p/345733012 的后面说到 “新版chrome内核已经无法获取明确的本地ip,而是一个指向本机ip的mDNS,导致在相同内网的不同设备无法走内网传输;” , 请问你这个项目能突破这个限制,实现内网传输吗?如果所有文件都必须经过中转服务器,那么就会严重受到服务器带宽限制了

服务访问异常

启动看着没问题,但是浏览器访问不了

做了些改动
[root@tool-10-0-0-13 tl-rtc-file]# cat Dockerfile
FROM node:14

WORKDIR /home/tlrtcfile

ADD . ./

COPY sources.list /etc/apt/sources.list

RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 0E98404D386FA1D9 &&
apt update &&
apt install -y libxtst-dev &&
npm conf set registry https://registry.npm.taobao.org/ &&
npm install -g pm2 &&
cd /home/tlrtcfile/svr/ &&
npm install &&
cd /home/tlrtcfile/svr/build/webpack/ &&
npm install

EXPOSE 9092 8444

CMD ["/bin/sh", "docker-entrypoint.sh"

[root@tool-10-0-0-13 tl-rtc-file]# cat docker-entrypoint.sh
#!/bin/bash

cd /home/tlrtcfile/svr

pm2 start npm --name=tlsocket -- run ssocket
pm2 start npm --name=tlapi -- run sapi

cd build/webpack

pm2 start npm --name=tlbuild -- run pro

pm2 logs --lines 1000

数据库连接已添加

image
image

安装成功的例子

  1. 开放端口 3478 9092
  2. git clone https://github.com/tl-open-source/tl-rtc-file.git
  3. cd tl-rtc-file/svr/
  4. npm install
  5. npm run build:pro
  6. npm run lsocket
  7. IP:9092
  8. git clone https://github.com/coturn/coturn.git
    腾讯云CentOS 8.4搭建coturn服务

用户名密码:tlrtcfile tlrtcfile 不是 admin 123456
https://blog.csdn.net/u012414498/article/details/129020739?spm=1001.2101.3001.6650.1&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-1-129020739-blog-121621052.235%5Ev38%5Epc_relevant_anti_t3_base&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-1-129020739-blog-121621052.235%5Ev38%5Epc_relevant_anti_t3_base&utm_relevant_index=2

8.sh start-local.sh # 缺少pm2就装npm install -g pm2
9.IP:9092

其他命令:
lsof -i tcp:8444
kill -9 1243894 #依端口停止应用
ps -ef | grep nginx | awk '{print $2}' | xargs kill -9#根据名字批量停止应用
image

握手失败通过tcp直连

我在一个有公网IP的服务器上部署,如果用户P2P握手失败,可以通过该服务器中转,保证连通性。

Docker部署后遇到的报错

按照如下步骤进行操作
image

执行镜像以后,镜像启动失败,报错如下:standard_init_linux.go:185: exec user process caused "exec format error"
image

操作系统:ubuntu16.04 server
docker版本:
image

请大佬帮忙看下,如何解决

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.