GithubHelp home page GithubHelp logo

nginx配置websocket报错 about tsrpc HOT 4 CLOSED

wmHappy avatar wmHappy commented on May 17, 2024
nginx配置websocket报错

from tsrpc.

Comments (4)

k8w avatar k8w commented on May 17, 2024

配置文件贴一下

from tsrpc.

wmHappy avatar wmHappy commented on May 17, 2024

#user root;
worker_processes 4;

#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

#pid logs/nginx.pid;

events {
worker_connections 102400;
accept_mutex on;
multi_accept on;
#use epoll;
}

http {
include mime.types;
default_type application/octet-stream;

access_log off;
sendfile on;
tcp_nopush on;

keepalive_timeout 55;

tcp_nodelay on;
client_header_buffer_size 4k;
client_body_buffer_size 512k;
open_file_cache max=102400 inactive=20s;
open_file_cache_valid 30s;
open_file_cache_min_uses 1;
client_header_timeout 15;
client_body_timeout 15;
reset_timedout_connection on;
send_timeout 15;
server_tokens off;
client_max_body_size 50m;

proxy_connect_timeout 5;
proxy_read_timeout 60;
proxy_send_timeout 5;
proxy_buffer_size 16k;
proxy_buffers 4 64k;
proxy_busy_buffers_size 128k;
proxy_temp_file_write_size 128k;

gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
#gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
gzip_vary off;
gzip_disable "MSIE [1-6].";
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 80;
server_name localhost;
#static file
location /{
root "D:/Program Files/Nginx/nginx-1.16.1/html/";
index index.html;
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';
}
location /niudu{
proxy_pass http://localhost:8887;
}
location /fish{
proxy_pass http://localhost:8890;
}
location /userApi{
proxy_pass http://localhost:8080;
}
location /matchApi{
proxy_pass http://localhost:8081;
}
location /roomApi{
proxy_pass http://localhost:8082;
}
location /user {
proxy_pass http://127.0.0.1:3001;
proxy_http_version 1.1;
proxy_read_timeout 3600s;
proxy_redirect off;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Connection keep-alive;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /match {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_read_timeout 3600s;
proxy_redirect off;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Connection keep-alive;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /room {
proxy_pass http://127.0.0.1:3002;
proxy_http_version 1.1;
proxy_read_timeout 3600s;
proxy_redirect off;
proxy_set_header Connection keep-alive;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~* .(html|htm|gif|jpg|jpeg|bmp|png|ico|txt|js|css)$ {
ssi on;
ssi_silent_errors on;
root "D:/Program Files/Nginx/nginx-1.16.1/html/";
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';
#index index1.html;
#cache
expires 7d;
}
}
}

from tsrpc.

wmHappy avatar wmHappy commented on May 17, 2024

<17816> 2022-10-19 19:46:10 [INFO] ::1 #1275 [Api:matchAdmin/RoomServerJoin] [ApiReq] { serverUrl: 'ws://127.0.0.1/match' }
<17816> 2022-10-19 19:46:10 [INFO] RS|ws://127.0.0.1/match TSRPC WebSocket Client : ws://127.0.0.1/match
<17816> 2022-10-19 19:46:10 [INFO] RS|ws://127.0.0.1/match Start connecting ws://127.0.0.1/match...
<17816> 2022-10-19 19:46:10 [INFO] RS|ws://127.0.0.1/match WebSocket connection to server successful
<17816> 2022-10-19 19:46:10 [INFO] RS|ws://127.0.0.1/match [ApiReq] #1 roomAdmin/Auth { type: 'MatchServer', token: '' }
匹配服务有连接被断开
<17816> 2022-10-19 19:46:10 [INFO] RS|ws://127.0.0.1/match Lost connection to ws://127.0.0.1/match code=1000 reason=Invalid request buffer, please check the version of service proto.
<17816> 2022-10-19 19:46:10 [ERROR] RS|ws://127.0.0.1/match [ApiErr] #1 roomAdmin/Auth TsrpcError {
message: 'Invalid request buffer, please check the version of service proto.',
type: 'NetworkError',
code: 'LOST_CONN'
}
<17816> 2022-10-19 19:46:10 [ERROR] ::1 #1275 [Api:matchAdmin/RoomServerJoin] [ApiErr] 18ms TsrpcError {
message: 'Invalid request buffer, please check the version of service proto.',
type: 'NetworkError',
code: 'LOST_CONN'
} req= { serverUrl: 'ws://127.0.0.1/match' }
这个是其中的一个打印日志

from tsrpc.

wmHappy avatar wmHappy commented on May 17, 2024

不好意思 问题找到了 是websocket连接的url地址 和发送的消息协议 不是同一个 也就是连接的匹配服务url 然后用了房间服务的serviceProto 发送了房间服务的消息内容 感谢作者您写的开源tsrpc 用起来很方便

from tsrpc.

Related Issues (20)

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.