Hyperf im open source! A chat system based on hyperf microservice framework + layim!

Time:2020-11-19

Thanks to the demo provided by SL im author, I just want to write a set of IM and rewrite it with hyperf

sl-im

hyperf-im


Hyperf im open source! A chat system based on hyperf microservice framework + layim!





brief introduction

hyperf-imIs based onHyperfMicroservice collaboration framework andLayimChat room developed by web chat system.

Experience address

hyperf-im im.jayjay.cn

function

1.0

  • Login registration (HTTP)
  • Single sign on (websocket)
  • Private chat (websocket)
  • Group chat (websocket)
  • Number of people online (websocket)
  • Get unread messages (websocket)
  • Friends online status (websocket)
  • Friend search add agree reject (HTTP + websocket)
  • Group create find add agree deny (HTTP + websocket)
  • Chat record storage
  • Heartbeat detection
  • message replay
  • Disconnection and reconnection
  • Send pictures and documents

1.1

  • Webrtc (video chat)

Requirement

Deployment mode

Composer

composer update

Env configuration

vim .env

WS_URL=wss://im.jayjay.cn/im
STORAGE_IMG_URL=$host/storage/upload/
STORAGE_FILE_URL=$host/file/upload/
APP_URL=https://im.jayjay.cn
WEB_RTC_URL=wss://im.jayjay.cn/video

Nginx configuration

server{
    listen 80;
    server_name im.jayjay.cn;
    return 301 https://$server_name$request_uri;
}

server{
    listen 443 ssl;
    root /data/wwwroot/;
    add_header Strict-Transport-Security "max-age=31536000";
    server_name im.jayjay.cn;
    access_log /data/wwwlog/im.jayjay.cn.access.log;
    error_log /data/wwwlog/im.jayjay.cn.error.log;
    client_max_body_size 100m;
    ssl_certificate /etc/nginx/ssl/full_chain.pem;
    ssl_certificate_key /etc/nginx/ssl/private.key;
    ssl_session_timeout 5m;
    ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
    location / {
        proxy_pass http://127.0.0.1:9501;
        proxy_set_header Host $host:$server_port;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Real-PORT $remote_port;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

    location /im {
        proxy_pass http://127.0.0.1:9502;
        proxy_http_version 1.1;
        proxy_read_timeout   3600s;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }

     location /video {
             proxy_pass http://127.0.0.1:9502;
             proxy_http_version 1.1;
             proxy_read_timeout   3600s;
             proxy_set_header Upgrade $http_upgrade;
             proxy_set_header Connection "upgrade";
     }


    location ~ .*\.(js|ico|css|ttf|woff|woff2|png|jpg|jpeg|svg|gif|htm)$ {
        root /data/wwwroot/IM/public;
    }
}

Start

  • Hang up
php bin/hyperf.php start

TODO

1. Improve the overall project

2. Rabbitmq message record to see if it is distributed next

contact information

  • WeChat:naicha_1994
  • QQ:847050412

License

LICENSE

Update records

The problem of redirecting to port 443 without logging in to chat room is solved.

This work adoptsCC agreementThe author and the link to this article must be indicated in the reprint

Recommended Today

Explain module, import and export in JavaScript

Author: Tania rascia Crazy technology house Original text:https://www.taniarascia.com/j… In the era of the Internet, websites are mainly developed with HTML and CSS. If you load JavaScript into a page, it usually provides effects and interactions in the form of small fragments. Generally, all JavaScript code is written in a file and loaded into a filescriptTag. […]